Page 1 of 2

[Solved] Deselecting an Editbox

Posted: Tue Nov 21, 2017 20:05
by Anasky
Heya,

I've recently started adding Editboxes to my UI, and they work fine, so yay.
What I do notice though is that if I press anywhere else, the editbox doesn't get deselected. It only gets deselected when I press another editbox or a button.

Is there a way that I can solve this, and also make it so that [Enter] deselect it as well?

Thanks in advance!
Anasky

Re: Deselecting an Editbox

Posted: Tue Nov 21, 2017 21:17
by Ident
Use deactivate/activate and isActive/GetActiveChild etc. for setting focussed windows or unsetting them

Re: Deselecting an Editbox

Posted: Tue Nov 21, 2017 22:27
by Anasky
How would that solve my issue?

-> client tells CEGUI a mouse button has been pressed
-> either CEGUI changes the selected child, or doesn't.
-> if it does, it's fine
-> if it doesn't, should I deselect the currently selected item? what if they just clicked the same editbox again? I shouldn't deselect it in that case?


Just in case clarifying would help:
- I have a root window
- With an editbox on it
- I select the editbox, and type
- Then I press somewhere else in my screen
- --> Editbox is still selected <-- (Clicking somewhere else should deselect the editbox?)

Re: Deselecting an Editbox

Posted: Tue Nov 21, 2017 22:38
by Ident
Is your root window able to steal activation? Afaik there can only be one active Window, so.... Did you check if it gets selected if you click it (check with the functions i mentioned, e.g. use a click handler and output to console if it is active, when the click happens, maybe you need to click twice though to be sure the internal handling doesnt happen after the handler and be sure to return false in the handler so you dont intercept)

Re: Deselecting an Editbox

Posted: Wed Nov 22, 2017 07:24
by Anasky
How would I allow my root window to steal activation?

The activating of the editbox works, I can see it selecting the widget and I can start typing in it, so that part works fine :)
I tried adding a click handler with an empty function to the root window, but that didn't seem to work? What method would be needed for this?

Re: Deselecting an Editbox

Posted: Wed Nov 22, 2017 19:59
by Ident
Anasky wrote:How would I allow my root window to steal activation?

The activating of the editbox works, I can see it selecting the widget and I can start typing in it, so that part works fine :)
I tried adding a click handler with an empty function to the root window, but that didn't seem to work? What method would be needed for this?

??? What what would an empty function do?


You can btw subscribe a handler for input events and check if the input is an Enter key and if so you can do deactivate on the Window*. Isnt that what you wanted?

Re: Deselecting an Editbox

Posted: Thu Nov 23, 2017 14:15
by Anasky
That would solve 1 of the 2 questions, thanks :)

What remains would be clicking outside the editbox.
So clicking anywhere on the screen that is not an editbox -> deselect the active window.

Re: Deselecting an Editbox

Posted: Thu Nov 23, 2017 18:39
by Ident
click handler for the other window (root?), in the function you deactivate whatever is clicked which you can find out with the functions i mentioned above.

Re: Deselecting an Editbox

Posted: Fri Nov 24, 2017 07:48
by Anasky
That's what I'm trying to do, but it doesn't work :(

I've added a handler to EVERY widget that I have using:
CEGUI::Window* l_NewWindow;
//...
l_NewWindow->subscribeEvent( CEGUI::PushButton::EventClicked, CEGUI::SubscriberSlot( &OpenGLLib::GUIFramework::clsWidget::Activate, this ) );

and the activate function I made having a breakpoint in it.
However, the breakpoint is never triggered...
Am I using the wrong type of event perhaps?

Re: Deselecting an Editbox

Posted: Fri Nov 24, 2017 07:58
by Ident
Yes, wrong event.

Re: Deselecting an Editbox

Posted: Fri Nov 24, 2017 08:34
by Anasky
Ident wrote:Yes, wrong event.


CEGUI::PushButton::EventMouseClick

Thanks for the help :)

Re: Deselecting an Editbox

Posted: Fri Nov 24, 2017 18:57
by Ident
Anasky wrote:
Ident wrote:Yes, wrong event.


CEGUI::PushButton::EventMouseClick

Thanks for the help :)

Isnt there a Window:EventMouseClick?

Not every window is a pushbutton.

Re: Deselecting an Editbox

Posted: Fri Dec 01, 2017 14:20
by Anasky
Ident wrote:
Anasky wrote:
Ident wrote:Yes, wrong event.


CEGUI::PushButton::EventMouseClick

Thanks for the help :)

Isnt there a Window:EventMouseClick?

Not every window is a pushbutton.


namespace CEGUI has no member EventMouseClick.
The PushButton version works though :)

Re: Deselecting an Editbox

Posted: Fri Dec 01, 2017 21:56
by Ident
Why dont you do a full-text search?

Window::EventMouseClick is what you want.

Re: Deselecting an Editbox

Posted: Sat Dec 02, 2017 12:44
by Anasky
Ident wrote:Why dont you do a full-text search?

Window::EventMouseClick is what you want.


Misread your last reply, my bad.
Yeah, Window::EventMouseClick does work ^^

Any clue how I can hide the password entered? I found the "setMaskCodePoint" on the forum questions, but that seems to be legacy code, and couldn't find anything on the tutorial page of the wiki.