IGUIElement and keyfocus

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Guest

IGUIElement and keyfocus

Post by Guest »

hi

i'm somewhat stuck here.
is it possible for an IGUIElement to know if it has the keyfocus?
i want to paint some highlighting if it has the focus and don't know how to verify that.

i could wait for the first key event to be routed to the element but i'd like to highlight things just when the focus is transmitted.

the IGuiEnvironment::setKeyFocus(...) doesn't seam to notify the element that it just has got the focus. :?

thanks for hints and ideas
tom
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Why do you need an on event for your GUI Control?

You could do your gui changes just after you set focus...

guienv->setKeyFocus(myElement);
myElement->doGraphicChange();
Crud, how do I do this again?
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Hi saigumi

I think the Environment should send a EGET_ELEMENT_KEY_FOCUS_GAINED event to the IGUIElement if the function

Environment->setKeyFocus(myelement);

was called, as it does for EGET_ELEMENT_KEY_FOCUS_LOST events when the function

Environment->removeKeyFocus(myelement);

is called.

This way we could handle keyfocus gained and keyfocus lost events in a similar way, that is, in the event handler of the gui-element where it belongs. I think the current behaviour is a bug because there is no consistent way for notifying the elements about keyfocus gained events.

cheers
tom
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

( be careful of the use of the word bug-- a bug is a piece of code which does not operate as expected by the coder. its not a word you should just throw around. since the code you mentioned is operating as expected, I think in this instance it sounds more like you mean "I think the current behaviour is inadequate" )
a screen cap is worth 0x100000 DWORDS
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

keless wrote:( be careful of the use of the word bug-- a bug is a piece of code which does not operate as expected by the coder. its not a word you should just throw around. since the code you mentioned is operating as expected, I think in this instance it sounds more like you mean "I think the current behaviour is inadequate" )
:D , you're right its inadequate :) , maybe?

i'd expect the behaviour i just described, if my words seem rude its because i'm no native english speaker :( , sorry about that :)

wouldn't it be much easier if the elements would be notified about the keyfocus gained events.
if i remove the focus from an object i don't have to notify it myself, but if i set to focus to it i have to?
if i have code that circels through all gui events and sets the keyfocus to one after the ofther i should have some interface to notify the elements, don't i? having the event sent to the element just seams the easiest solution.
with this said: it's not a bug, but a missing feature :?

what do you think?
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

( dont mind me, i havent had my coffee. no harm done :) )

yes, i think the GUI system is definately not robust enough yet. its something Niko said he was going to work on. Saigumi has been doing a lot of work modifying it on his own for now. I wonder how he feels about your suggestion (if its neccesary in practice or not)?

The GUI system certainly needs an input box of some sort.
a screen cap is worth 0x100000 DWORDS
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

I'm trying to build a GUIConsole, that's why I'm so keen on the GUI stuff :)
For now its almost done, but it has to be used with my own GUIWindow class because of the event notification stuff.
I think the gui is not bad, there are just some small point where one gets stuck but it shure is as easy to use as the rest of irrlicht.
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

The GUI handling is lacking in a lot of facets. Like an ON_FOCUS event. I've been plugging away at it and send things that I find to Niko.

I'm currently comparing the ISceneNode and IGUIElement classes to find inconsistencies between the two and attempting to repair them myself. This way, I can learn more about the inner workings and if Niko likes my additions, it would mean that he has more time to concentrate on 3D stuffage that I know little about. I also started putting in comments for additional features that will bring it more robust like Visual Basic's controls.

I've been doing GUI stuff like this for 3 years, and the model I am using is a lot like a framework I used for ingame plugins called Decal (http://decaldev.sourceforge.net). My creation is Navi (http://navi3.sourceforge.net).

Then there are new Elements I want to release:

When I get back to it, I plan on finishing my Input box, which will be just a static text that handles keypresses and changes the text. Then use that to update my console control, which is just a listbox taped to the input box.

The progress bar was already brought up in another thread... and thats just about how I plan on implementing it.

A control I made a long time ago and scrapped, that I plan on bringing back or modifying the IGUIImage since it has all the properties already, just doesn't display it's Text, is an Icon (like Winders or Linux icons) that is just an image with text under it and click-ability.
Crud, how do I do this again?
Post Reply