Getting no WMHI_GADGETUP for button gadget
Post date
Sat, 03/30/2024 - 09:23
I'm working on the event loop for App I'm currently creating and so far I am not able to get a WMHI_GADGETUP event.
The window creation:
pWinObject = NewObject(WINDOW_GetClass(), NULL,
WINDOW_Position, WPOS_CENTERSCREEN,
WA_Activate, TRUE,
WA_Title, "MultiRename",
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_DepthGadget, TRUE,
WA_SizeGadget, TRUE,
WA_InnerWidth, 600,
WA_InnerHeight, 400,
WA_IDCMP, IDCMP_CLOSEWINDOW|IDCMP_GADGETUP,
WINDOW_Layout, pMainLayout,
TAG_DONE));
...
pIntuiWindow = (struct Window*)DoMethod(pApp->pWinObject, WM_OPEN, NULL);
The main layout is created in a function that looks like this:
Object* createLayout(void)
{
Object *pMainLayout = NULL, *pTopParentHLayout = NULL,
*pTopVLayoutName = NULL, *pTopVLayoutExt = NULL,
*pTopVLayoutCnt = NULL;
// Initialize CompareHook for sorting the "Old name" column
m_CompareHook.h_Entry = (ULONG (*)()) myCompare;
m_CompareHook.h_SubEntry = NULL;
m_CompareHook.h_Data = NULL;
m_pColumnInfo = AllocLBColumnInfo(2,
LBCIA_Column, 0,
LBCIA_Flags, CIF_WEIGHTED,
LBCIA_AutoSort, TRUE,
LBCIA_SortArrow, TRUE,
LBCIA_SortDirection, LBMSORT_FORWARD,
LBCIA_Title, "Old name",
LBCIA_Weight, 50,
LBCIA_Column, 1,
LBCIA_Flags, CIF_WEIGHTED,
LBCIA_Sortable, FALSE,
LBCIA_Title, "New name",
LBCIA_Weight, 50,
TAG_DONE);
pTopVLayoutName = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, (ULONG)"Name",
LAYOUT_AddChild, m_ppGadgets[GID_STRING_NAME] = NewObject(STRING_GetClass(), NULL,
GA_ID, GID_STRING_NAME,
STRINGA_TextVal, (ULONG)"[N]",
TAG_DONE),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_BTN_NAME] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_NAME,
GA_Text, (ULONG)"[N] Name",
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_NAME_DATE] = NewObject(BUTTON_GetClass(), NULL,
GA_Text, (ULONG)"[YMD] Date",
GA_ID, GID_BTN_NAME_DATE,
TAG_DONE),
TAG_DONE),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_BTN_NAME_PART] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_NAME_PART,
GA_Text, (ULONG)"[N#-#] Part",
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_NAME_TIME] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_NAME_TIME,
GA_Text, (ULONG)"[hms] Time",
TAG_DONE),
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_NAME_COUNTER] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_NAME_COUNTER,
GA_Text, (ULONG)"[C] Counter",
TAG_DONE),
TAG_DONE);
pTopVLayoutExt = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, (ULONG)"Extension",
LAYOUT_AddChild, m_ppGadgets[GID_STRING_EXTENSION] = NewObject(STRING_GetClass(), NULL,
GA_ID, GID_STRING_EXTENSION,
STRINGA_TextVal, (ULONG)"[E]",
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_EXTENSION] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_EXTENSION,
GA_Text, (ULONG)"[E] Ext.",
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_EXTENSION_PART] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_EXTENSION_PART,
GA_Text, (ULONG)"[E#-#] Part",
TAG_DONE),
LAYOUT_AddChild, m_ppGadgets[GID_BTN_EXTENSION_COUNTER] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_EXTENSION_COUNTER,
GA_Text, (ULONG)"[C] Counter",
TAG_DONE),
TAG_DONE),
pTopVLayoutCnt = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, (ULONG)"Define counter",
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_INTEGER_COUNTER_START] = NewObject(INTEGER_GetClass(), NULL,
GA_ID, GID_INTEGER_COUNTER_START,
GA_TabCycle, TRUE,
INTEGER_Number, 1,
INTEGER_MaxChars, 2,
INTEGER_Minimum, 0,
INTEGER_Maximum, 10,
TAG_DONE),
CHILD_Label, NewObject(LABEL_GetClass(), NULL, LABEL_Text, (ULONG)"Start:", TAG_DONE),
TAG_DONE),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_INTEGER_COUNTER_STEP] = NewObject(INTEGER_GetClass(), NULL,
GA_ID, GID_INTEGER_COUNTER_STEP,
GA_TabCycle, TRUE,
INTEGER_Number, 1,
INTEGER_MaxChars, 2,
INTEGER_Minimum, 1,
INTEGER_Maximum, 10,
TAG_DONE),
LABEL_Text, (ULONG)"Step",
CHILD_Label, NewObject(LABEL_GetClass(), NULL, LABEL_Text, (ULONG)"Step:", TAG_DONE),
TAG_DONE),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_CHOOSER_COUNTER_PLACES] = NewObject(CHOOSER_GetClass(), NULL,
GA_ID, GID_CHOOSER_COUNTER_PLACES,
GA_TabCycle, TRUE,
GA_RelVerify, TRUE,
CHOOSER_LabelArray, (ULONG)ppCounterPlaces,
CHOOSER_Justification, CHJ_RIGHT,
CHOOSER_Selected, 1,
CHOOSER_AutoFit, TRUE,
TAG_DONE),
CHILD_Label, NewObject(LABEL_GetClass(), NULL, LABEL_Text, (ULONG)"Places:", TAG_DONE),
TAG_DONE),
TAG_DONE);
pTopParentHLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_SpaceOuter, FALSE,
LAYOUT_AddChild, pTopVLayoutName,
CHILD_WeightedWidth, 70,
LAYOUT_AddChild, pTopVLayoutExt,
CHILD_WeightedWidth, 30,
LAYOUT_AddChild, pTopVLayoutCnt,
CHILD_WeightedWidth, 0,
TAG_DONE);
pMainLayout = NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
ICA_TARGET, ICTARGET_IDCMP, /* TODO: Remove this?? */
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_DeferLayout, TRUE, /* this tag instructs layout.gadget to
* defer GM_LAYOUT and GM_RENDER and ask
* the application to do them. This
* lessens the load on input.device
*/
LAYOUT_AddChild, (ULONG)pTopParentHLayout,
CHILD_WeightedHeight, 0,
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
LAYOUT_SpaceOuter, TRUE,
LAYOUT_BevelStyle, BVS_GROUP,
LAYOUT_Label, (ULONG)"Processing list",
LAYOUT_AddChild, m_ppGadgets[GID_LISTBROWSER] = NewObject(LISTBROWSER_GetClass(), NULL,
GA_ID, GID_LISTBROWSER,
GA_RelVerify, TRUE,
LISTBROWSER_ColumnInfo, (ULONG)m_pColumnInfo,
LISTBROWSER_ColumnTitles, TRUE,
LISTBROWSER_TitleClickable, TRUE,
TAG_DONE),
LAYOUT_AddChild, NewObject(LAYOUT_GetClass(), NULL,
LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
LAYOUT_AddChild, m_ppGadgets[GID_BTN_START] = NewObject(BUTTON_GetClass(), NULL,
GA_ID, GID_BTN_START,
GA_Text, (ULONG)"Start",
TAG_DONE),
CHILD_WeightedWidth, 0,
TAG_DONE),
CHILD_WeightedHeight, 0,
TAG_DONE),
TAG_DONE);
return pMainLayout;
}
And the event loop looks like this:
ULONG winSig;
ULONG receivedSig;
ULONG result;
ULONG code;
BOOL end = FALSE;
GetAttr(WINDOW_SigMask, pWinObject, &winSig);
while (!end)
{
receivedSig = Wait(winSig);
while ((result = DoMethod(pWinObject, WM_HANDLEINPUT, &code)))
{
switch (result & WMHI_CLASSMASK)
{
case WMHI_CLOSEWINDOW:
end = TRUE;
break;
case WMHI_GADGETUP:
printf("GADGETUP\n");
switch(result & WMHI_GADGETMASK)
{
case GID_BTN_NAME:
printf("Name button\n");
break;
}
break;
}
}
}
I expect that every time I click on any button, "GADGETUP" is print and when I click on "[N] Name", "Name button" is also output (because the two printf in the event loop).
But this is not happening. But "GADGETUP" is printed each time the ListBrowser column title is clicked.
What am I doing wrong?
Post date
Saturday, March 30, 2024 - 11:15
I have temporarily set the repository to public: MultiRename @ Github
The code snippets I posted here can be found in src/application.c
Post date
Sunday, March 31, 2024 - 11:29
you need GA_RelVerify, TRUE,
on any gadget you want to have gadget up events from
Online Status
Might be easier to assist if you cam let us see the source code as a whole rather than snippets