String gadget events?

7 posts / 0 new
Last post
AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 3 months ago
Joined: 2012-02-18 19:55
String gadget events?

Hello,

trying to understand how Amiga programming works.

I have this source to open a window containing a string gadget:

Object *open_text_window_new(struct Screen *scr, struct Menu *menu)
{

Object *winobj;

if ((winobj = WindowObject,
WA_PubScreen, scr,
WA_Title, "My Window",
WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEBBOTTOM | WFLG_SIZEGADGET | WFLG_ACTIVATE,
WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_INTUITICKS,
WA_Width, scr->Width * 6 / 10,
WA_Height, scr->Height * 4 / 10,
WINDOW_MenuStrip,menu,
WINDOW_BackFillName, "Sys:Prefs/Presets/Patterns/Chalk/ChalkBlue.brush",
WINDOW_Position, WPOS_TOPLEFT,
WINDOW_ParentGroup, VGroupObject,
LAYOUT_AddChild, VLayoutObject,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, " Welcome",
LAYOUT_AddChild, StringObject,
GA_ID, GID_STRING1,
GA_RelVerify, TRUE,
GA_TabCycle, TRUE,
STRINGA_MinVisible, 20,
STRINGA_MaxChars, SMAX,
EndObject,
CHILD_Label, LabelObject, LABEL_Text, "This is a label:",
End,
End,
LAYOUT_AddChild, HLayoutObject,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,

EndHGroup,
EndVGroup,
EndWindow))

return (winobj);

}

Now, how can i access the string getting the text after press enter or other events?
What to do in my program loop?

Thank you very much.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 3 months ago
Joined: 2012-02-18 19:55
Thank you,

Thank you, Hans

Studying...

About the reaction macros, i'm avoiding now... thanks to your suggestions and thanks to trixie's articles.
My problem is that i can't find tutorial that are made without reaction macros. Event in the sdk there are only fews examples done without reaction macros.

salass00
salass00's picture
Offline
Last seen: 1 month 3 days ago
Joined: 2011-02-03 11:27
You have to listen for


You have to listen for OM_NOTIFY messages from the string object. As per the string class docs, you will receive a message with GA_ID = GID_STRING1 (the ID that you gave the string gadget), and a STRINGA_TextVal attribute containing the string.

A generally more convenient way would be to listen for WMHI_GADGETUP events and use GetAttr() to obtain the new string value. By default string.gadget only sends a GADGETUP when the gadget is exited by pressing return or enter but this can be changed by setting STRINGA_RelVerifySpecial to TRUE.

salass00
salass00's picture
Offline
Last seen: 1 month 3 days ago
Joined: 2011-02-03 11:27
Ugh! I just realised that


Ugh! I just realised that OM_NOTIFY is a BOOPSI method, not a message. So, listening for WMHI_GADGETUP events is the correct way to do this.

If you set ICA_TARGET to ICTARGET_IDCMP you will get them as IDCMP_IDCMPUPDATE messages but you will need to use an IDCMP hook to intercept them as there is no WMHI_ equivalent for this type of event.

AmigaBlitter
AmigaBlitter's picture
Offline
Last seen: 6 years 3 months ago
Joined: 2012-02-18 19:55
@salass00 have you got my

@salass00
have you got my e-mail, perhaps?

Log in or register to post comments