[Solved] Deselecting an Editbox

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

[Solved] Deselecting an Editbox

Postby Anasky » Tue Nov 21, 2017 20:05

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

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Tue Nov 21, 2017 21:17

Use deactivate/activate and isActive/GetActiveChild etc. for setting focussed windows or unsetting them
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Tue Nov 21, 2017 22:27

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?)

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Tue Nov 21, 2017 22:38

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)
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Wed Nov 22, 2017 07:24

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?

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Wed Nov 22, 2017 19:59

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?
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Thu Nov 23, 2017 14:15

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.

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Thu Nov 23, 2017 18:39

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.
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Fri Nov 24, 2017 07:48

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?

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Fri Nov 24, 2017 07:58

Yes, wrong event.
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Fri Nov 24, 2017 08:34

Ident wrote:Yes, wrong event.


CEGUI::PushButton::EventMouseClick

Thanks for the help :)

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Fri Nov 24, 2017 18:57

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.
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Fri Dec 01, 2017 14:20

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 :)

User avatar
Ident
CEGUI Team
Posts: 1836
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: Deselecting an Editbox

Postby Ident » Fri Dec 01, 2017 21:56

Why dont you do a full-text search?

Window::EventMouseClick is what you want.
CrazyEddie: "I don't like GUIs"

Anasky
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Mon Sep 25, 2017 21:34

Re: Deselecting an Editbox

Postby Anasky » Sat Dec 02, 2017 12:44

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.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest