Hi,
Does it exist, in Reaction, a way to make an Object active without user input ?
For example, in a window with a simple "OK" button, is there a way to make this button active ? A simple "Return" key press will press it ?
In MUI, there is a "set(window,MUIA_Window_ActiveObject,MyButton);". any Reaction equivalent ?
I tried,
IIntuition->ActivateGadget(GAD(OBJ_ABT_OK), window_About,NULL) ;
without success...
Thank you
ILayout->ActivateLayoutGadget
If your layout is in a reaction window.class window then you should use:
WM_ACTIVATEGADGET -- Activate layout gadget.
If the layout is attached to a plain intuition window / requester
Use ILayout->ActivatelayoutGadget()
But neither of those will achieve the button being pressed from keyboard....
Instead you can set the keyboard shortcut via the gadget text by placing an under score just before the letter you want as the shortcut.
eg
GA_Text,"_OK",
Will display as button with an OK with the O underlined, pressing O wil then 'press' the button.
You can also specify the shortcut key with:
GA_ActivateKey (CONST_STRPTR)
I'm not sure if that will enable keys like Return or Esc though, for those keys you will have to listen to WMHI_RAWKEY and detect a keyup event for the corresponding key, then trigger the same bit of code that pressing the key would have.
Thank you Thomas and Andy
I still used "_OK" and ActivateKey. it doesn't make the object active.
I tried too ActivateLayoutGadget without more success.
If I have to use RAWKEY only for that it seems a lit bit too much complicated.
Thx again
Typing "O" doesn't depress the OK button? Does it display with a underlined 'O' ?
Similar code does work here in my own about window. I will email you it.
Yes, pressing "O" activate and press the button. No problem for that, sorry if my initial post was not enough clear.
My initial question was about Enter key press. In MUI, an activated button with MUIA_Window_ActiveObject reacts to Enter key.
Buttons wont listen to the enter key in that way as Enter is not meaningful to a button, if you want enter or esc to close your about window then you need to add WMHI_RawKey and check for the keypress.
Thank you for the explanation,
Solved by using RAWKEY
case WMHI_RAWKEY:
{
struct InputEvent *ie;
GetAttr(WINDOW_InputEvent,win_About,(ULONG *)&ie);
// 67 = NumPad Return
// 68 = Return key
if ( (ie->ie_Code == 67) || (ie->ie_Code == 68) )
{
doneAbout = TRUE;
}
}