Hello,
I'm now working on my game. And currently i'm focusing on game-built-in map editor.
Now I want to implement "delete" function, that allow users delete their objects from scene when pressing "delete" button.
To achieve that, a event handler is attached to editor root window to deal with the key event.
The problems is, this deleting operation should be blocked when user is editing properties, for example, when a user is deleting
the numbers in position attribute, he won't see his object disappeared instead.
I have tried isActive(), isCapturedByThis(), isCapturedByChild(), they all didn't work.
So now I'm going to try hasInputFocus() of Editbox. But I have to get all editbox from root window and inspect them.
How can I do this, instead of add those editbox one by one manually?
Or is there any other solutions?
Thank you.
And to those who are curious about my work, here is the github link:
https://github.com/DarkAngelZT/NeoGameF ... ee/tankwar
--update---
I tried just investigate one of the editbox, it seems the input focus is not gone when I click out side of the editbox
So now the question is how to know if a window is getting focus?
[Resolved somehow] How to know if the window has got focus?
Moderators: CEGUI MVP, CEGUI Team
[Resolved somehow] How to know if the window has got focus?
Last edited by Neo on Tue Nov 22, 2016 23:18, edited 1 time in total.
Re: How to know if the window has got focus?
isActive() is the right function
Can you still type into it? Then isActive() should return true. It is expected behaviour.
If you do not want this to happen, then whatever you clicked on needs to be able to receive focus.
it seems the input focus is not gone when I click out side of the editbox
Can you still type into it? Then isActive() should return true. It is expected behaviour.
If you do not want this to happen, then whatever you clicked on needs to be able to receive focus.
CrazyEddie: "I don't like GUIs"
Re: How to know if the window has got focus?
Yes I can still type.
The editbox is attached to a root window. The root window is just a default empty window act as a ui sheet,
The editbox will only become unable to type in when I click on another frame window or widget, but click on the root window area makes no sense
The editbox is attached to a root window. The root window is just a default empty window act as a ui sheet,
The editbox will only become unable to type in when I click on another frame window or widget, but click on the root window area makes no sense
Re: How to know if the window has got focus?
Neo wrote:The editbox will only become unable to type in when I click on another frame window or widget, but click on the root window area makes no sense
Can you try, just for testing, to make your root window a FrameWindow instead of a Defaultwindow to see if the behaviour changes?
The point is that the root window needs to be able to get focus.
If the above test does not work then I suggest the following:
Subscribe to the root window's event handler for mouse click, inside it call the focus() function of your root window and then return false. Havent tested this yet though, but I looked into the code and that should do the trick.
CrazyEddie: "I don't like GUIs"
Re: How to know if the window has got focus?
Ident wrote:The point is that the root window needs to be able to get focus.
Yes it can get focus when root window is a frame window. The problem is the result of isActive() is always true, no matter the root window is default window or frame window, even if I am typing in the editbox.
Re: How to know if the window has got focus?
Ok I think I misunderstood you at first.
So what you want in the end is a way to say isAnyEditboxBeingEdited() is that right? So you wanna know if any of the editboxes has focus, meaning that it would be receiving a DEL key input if the button was pressed.
So what you want in the end is a way to say isAnyEditboxBeingEdited() is that right? So you wanna know if any of the editboxes has focus, meaning that it would be receiving a DEL key input if the button was pressed.
CrazyEddie: "I don't like GUIs"
Re: How to know if the window has got focus?
Ident wrote:Ok I think I misunderstood you at first.
So what you want in the end is a way to say isAnyEditboxBeingEdited() is that right?
Yes, absolutely
In normal system widget programming, root window will lose focus when you are editing editbox. But in cegui, the root window still labelled as active while typing in the editbox.
Re: How to know if the window has got focus?
Neo wrote:In normal system widget programming, root window will lose focus when you are editing editbox. But in cegui, the root window still labelled as active while typing in the editbox.
I would like to believe that is true, but can you give me some examples / sources on that? If this is a general pattern used in widget systems, then I would like to switch to this for 1.0.
There is a function getActiveChild() which looks for the topmost-drawn active window. I think what you can do is to: call it on the root window everytime you wanna delete a game entity in your editor then check if the active window is a editbox (or whatever else you want to check) - and you should be good. Tell me if this works
CrazyEddie: "I don't like GUIs"
Re: How to know if the window has got focus?
Ident wrote:can you give me some examples / sources on that? If this is a general pattern used in widget systems, then I would like to switch to this for 1.0.
Do you mean you want a general code example other than cegui? I think I can make a simple x11 window and test how it works. Just give me some time to review my system coding lessons before I can provide a sample code XD
Ident wrote:There is a function getActiveChild() which looks for the topmost-drawn active window. I think what you can do is to: call it on the root window everytime you wanna delete a game entity in your editor then check if the active window is a editbox (or whatever else you want to check) - and you should be good. Tell me if this works
This one works! I can get to know which window is capturing event in every key up event!
This line will give me the certain type string, despite whatever widget name is.(It's lua code)
Code: Select all
g_ui_table.editor:getActiveChild():getType()
Re: How to know if the window has got focus?
Neo wrote:Ident wrote:can you give me some examples / sources on that? If this is a general pattern used in widget systems, then I would like to switch to this for 1.0.
Do you mean you want a general code example other than cegui? I think I can make a simple x11 window and test how it works. Just give me some time to review my system coding lessons before I can provide a sample code XD
I meant libraries as examples, so x11 is one.
Neo wrote:Ident wrote:There is a function getActiveChild() which looks for the topmost-drawn active window. I think what you can do is to: call it on the root window everytime you wanna delete a game entity in your editor then check if the active window is a editbox (or whatever else you want to check) - and you should be good. Tell me if this works
This one works! I can get to know which window is capturing event in every key up event!
This line will give me the certain type string, despite whatever widget name is.(It's lua code)Code: Select all
g_ui_table.editor:getActiveChild():getType()
Glad to have helped, I assume this is resolved then
CrazyEddie: "I don't like GUIs"
Re: [Resolved somehow] How to know if the window has got focus?
Thanks. And now I find that I can use deactivate() to forcefully remove input focus on active edit box if I click the empty area of root default window .
As I said before, input focus will stay in edit box you click on the empty default window, unless a widget like a frame window or list item is clicked.
As I said before, input focus will stay in edit box you click on the empty default window, unless a widget like a frame window or list item is clicked.
Who is online
Users browsing this forum: No registered users and 25 guests