How to change current clicktab

19 posts / 0 new
Last post
alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
How to change current clicktab

I have a window with a lot of gui stuff going on, among other things a clicktab object with two tabs. Now, when a certain event happens, I want to be able to switch to tab number two, and I am trying to do it with this code:

  1. IIntuition->SetAttrs(ClickTabObj, CLICKTAB_Current, (uint16)1, TAG_DONE);

...which is obviously wrong, because it either locks up the program or does some weird stuff showing the tab at (0,0) offset in the window. So what am I supposed to do?

afxgroup
afxgroup's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 15:26
Try

Try with

  1. IIntuition->SetGadgetAttrs( ClickTabObj, yourWindow, NULL,
  2. CLICKTAB_Current, 1,
  3. TAG_END
  4. );
alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Still doesn't work. Just

Still doesn't work. Just hangs up the program and I have to reboot... :-/

trixie
trixie's picture
Offline
Last seen: 7 months 3 weeks ago
Joined: 2011-02-03 13:58
Re: How to change current clicktab

@ alfkil

I assume you have a page object attached to the clicktab via CLICKTAB_PageGroup?

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

afxgroup
afxgroup's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 15:26
That's strange.. i use it

That's strange.. i use it without any problem..

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
Still doesn't work. Just

Still doesn't work. Just hangs up the program and I have to reboot... :-/

"yourWindow" must be a pointer to struct Window, not the window object.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
@trixie Yes, I have a

@trixie

Yes, I have a PageGroup attached to it. Do I need to detach that or smth??

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
@thomas Yes, I am using the

@thomas

Yes, I am using the struct Window pointer, not the Object.

afxgroup
afxgroup's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 15:26
I think the problem is

I think the problem is elsewhere. Do you have a stacktrace?

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
@afxgroup No, but I can list

@afxgroup

No, but I can list the code that generates the clicktab object:

  1. LAYOUT_AddChild, HLayoutObject,
  2. LAYOUT_AddChild, ClickTabObj = ClickTabObject,
  3. GA_Text, PageLabels_1,
  4.  
  5. CLICKTAB_Current, 0,
  6. CLICKTAB_PageGroup, PageObject,
  7. PAGE_Add, VLayoutObject,
  8. //LAYOUT_SpaceOuter, TRUE,
  9. //LAYOUT_DeferLayout, TRUE,
  10. LAYOUT_AddChild, SourceListBrowserObj = ListBrowserObject,
  11. GA_ID, GAD_SOURCE_LISTBROWSER,
  12. GA_RelVerify, TRUE,
  13. GA_TabCycle, TRUE,
  14. LISTBROWSER_AutoFit, TRUE,
  15. LISTBROWSER_Labels, &source_list,
  16. LISTBROWSER_ColumnInfo, sourcecolumninfo,
  17. LISTBROWSER_ColumnTitles, TRUE,
  18. LISTBROWSER_ShowSelected, TRUE,
  19. //LISTBROWSER_Striping, LBS_ROWS,
  20. ListBrowserEnd,
  21. EndMember,
  22.  
  23. PAGE_Add, VLayoutObject,
  24. LAYOUT_AddChild, DisassemblerListBrowserObj = ListBrowserObject,
  25. GA_ID, GAD_DISASSEMBLER_LISTBROWSER,
  26. GA_RelVerify, TRUE,
  27. GA_TabCycle, TRUE,
  28. //GA_TextAttr, &courier_font,
  29. LISTBROWSER_AutoFit, TRUE,
  30. LISTBROWSER_Labels, &disassembly_list,
  31. LISTBROWSER_ShowSelected, TRUE,
  32. LISTBROWSER_Striping, LBS_ROWS,
  33. ListBrowserEnd,
  34.  
  35. LAYOUT_AddChild, HLayoutObject,
  36. LAYOUT_AddChild, DisassemblerStepButtonObj = ButtonObject,
  37. GA_ID, GAD_DISASSEMBLER_STEP_BUTTON,
  38. GA_RelVerify, TRUE,
  39. GA_Text, "Step",
  40. ButtonEnd,
  41. CHILD_WeightedHeight, 0,
  42.  
  43. LAYOUT_AddChild, DisassemblerSkipButtonObj = ButtonObject,
  44. GA_ID, GAD_DISASSEMBLER_SKIP_BUTTON,
  45. GA_RelVerify, TRUE,
  46. GA_Text, "Skip",
  47. ButtonEnd,
  48. CHILD_WeightedHeight, 0,
  49. EndMember,
  50. CHILD_WeightedHeight, 0,
  51. EndMember,
  52. PageEnd,
  53. EndMember,
afxgroup
afxgroup's picture
Offline
Last seen: 6 months 2 weeks ago
Joined: 2011-02-03 15:26
It's hard to understand where

It's hard to understand where could be the problem without any stack trace.. you should buy a cheap null modem cable to print the output.. or try to get it with DumpDebugBuffer

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
I already have a serial

I already have a serial connection on my skod-pc, but I don't get a trace. Instead, the tab is shown at window coords (0, 0) on top of my window bare and everything else... I think there must be something wrong with the way I am configuring my objects. Strange though, that everything works perfectly normal when I just select the tabs with the mouse...

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
I have tried with a small

I have tried with a small modification of one of the sdk reaction examples, and here it also doesn't work. If I don't refresh the gadgets, then page two is NOT shown, but becomes temporarily unavailable until I press page 3. If I DO refresh, page 2 is shown at window coords (0, 0), Does anyonw have a (small) example where it actually works??

  1. ;/* Execute me to compile:
  2. gcc -o ClickTabExample ClickTabExample.c -lauto
  3. quit
  4. */
  5.  
  6. #include <dos/dos.h>
  7. #include <intuition/intuition.h>
  8. #include <classes/window.h>
  9. #include <gadgets/layout.h>
  10. #include <gadgets/clicktab.h>
  11.  
  12. #include <proto/exec.h>
  13. #include <proto/intuition.h>
  14. #include <proto/window.h>
  15. #include <proto/layout.h>
  16. #include <proto/clicktab.h>
  17.  
  18.  
  19. #define OBJ(x) Objects[x]
  20. #define GAD(x) (struct Gadget *)Objects[x]
  21.  
  22.  
  23. Object *win;
  24.  
  25. struct MsgPort *AppPort;
  26.  
  27. enum
  28. {
  29. OBJ_CLICKTAB_1,
  30. OBJ_CLICKTAB_2,
  31. OBJ_BUTTON,
  32. OBJ_QUIT,
  33. OBJ_NUM
  34. };
  35.  
  36. Object *Objects[OBJ_NUM];
  37.  
  38. STRPTR PageLabels_1[] = {"Tab 1", "Tab 2", "Tab 3", NULL};
  39. STRPTR PageLabels_2[] = {"Tab 3a", "Tab 3b", NULL};
  40.  
  41. struct Hook newprefshook;
  42.  
  43.  
  44. VOID prefshookfunc( struct Hook *me, APTR winobj, APTR reserved )
  45. {
  46. IExec->DebugPrintF("new prefs hook called\n");
  47. }
  48.  
  49.  
  50. Object *
  51. make_window(void)
  52. {
  53. /* create hook */
  54. newprefshook.h_Entry = (HOOKFUNC)prefshookfunc;
  55. newprefshook.h_SubEntry = NULL;
  56. newprefshook.h_Data = NULL;
  57.  
  58. Object
  59. *page1 = NULL,
  60. *page2 = NULL,
  61. *page3 = NULL,
  62. *page3a = NULL,
  63. *page3b = NULL;
  64.  
  65. // Some CHILD_WeightedHeight tags have been left
  66. // out to demonstrate the effects of the tag.
  67.  
  68. page1 = IIntuition->NewObject(NULL, "layout.gadget",
  69. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  70. LAYOUT_BevelStyle, BVS_GROUP,
  71. LAYOUT_Label, "Page One",
  72. LAYOUT_AddChild, OBJ(OBJ_BUTTON) = IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button One", GA_ID, OBJ_BUTTON, GA_RelVerify, TRUE, TAG_DONE),
  73. CHILD_WeightedHeight, 0,
  74. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Two", TAG_DONE),
  75. CHILD_WeightedHeight, 0,
  76. TAG_DONE);
  77.  
  78. page2 = IIntuition->NewObject(NULL, "layout.gadget",
  79. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  80. LAYOUT_BevelStyle, BVS_GROUP,
  81. LAYOUT_Label, "Page Two",
  82. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Three", TAG_DONE),
  83. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Four", TAG_DONE),
  84. TAG_DONE);
  85.  
  86. page3a = IIntuition->NewObject(NULL, "layout.gadget",
  87. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  88. LAYOUT_AddChild, IIntuition->NewObject(NULL, "layout.gadget",
  89. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Five", TAG_DONE),
  90. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Six", TAG_DONE),
  91. TAG_DONE),
  92. CHILD_WeightedHeight, 0,
  93. TAG_DONE);
  94.  
  95. page3b = IIntuition->NewObject(NULL, "layout.gadget",
  96. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  97. LAYOUT_AddChild, IIntuition->NewObject(NULL, "layout.gadget",
  98. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Seven", TAG_DONE),
  99. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "Button Eight", TAG_DONE),
  100. TAG_DONE),
  101. CHILD_WeightedHeight, 0,
  102. TAG_DONE);
  103.  
  104. page3 = OBJ(OBJ_CLICKTAB_2) = IIntuition->NewObject(NULL, "clicktab.gadget",
  105. GA_Text, PageLabels_2,
  106. CLICKTAB_Current, 0,
  107. CLICKTAB_PageGroup, IIntuition->NewObject(NULL, "page.gadget",
  108. PAGE_Add, page3a,
  109. PAGE_Add, page3b,
  110. TAG_DONE),
  111. TAG_DONE);
  112.  
  113. OBJ(OBJ_CLICKTAB_1) = IIntuition->NewObject(NULL, "clicktab.gadget",
  114. GA_Text, PageLabels_1,
  115. CLICKTAB_Current, 0,
  116. CLICKTAB_PageGroup, IIntuition->NewObject(NULL, "page.gadget",
  117. PAGE_Add, page1,
  118. PAGE_Add, page2,
  119. PAGE_Add, page3,
  120. TAG_DONE),
  121. TAG_DONE);
  122.  
  123. return IIntuition->NewObject(NULL, "window.class",
  124. WA_ScreenTitle, "ReAction Example",
  125. WA_Title, "ClickTab Example",
  126. WA_DragBar, TRUE,
  127. WA_CloseGadget, TRUE,
  128. WA_SizeGadget, TRUE,
  129. WA_DepthGadget, TRUE,
  130. WA_Activate, TRUE,
  131. WINDOW_IconifyGadget, TRUE,
  132. WINDOW_IconTitle, "Iconified",
  133. WINDOW_AppPort, AppPort,
  134. WINDOW_NewPrefsHook, &newprefshook,
  135. WINDOW_Position, WPOS_CENTERSCREEN,
  136. WINDOW_Layout, IIntuition->NewObject(NULL, "layout.gadget",
  137. LAYOUT_Orientation, LAYOUT_ORIENT_VERT,
  138.  
  139. LAYOUT_AddChild, OBJ(OBJ_CLICKTAB_1),
  140.  
  141. LAYOUT_AddChild, IIntuition->NewObject(NULL, "button.gadget", GA_Text, "_Quit", GA_ID, OBJ_QUIT, GA_RelVerify, TRUE, TAG_DONE),
  142. CHILD_WeightedHeight, 0,
  143.  
  144. TAG_DONE),
  145. TAG_DONE);
  146. }
  147.  
  148.  
  149. int
  150. main()
  151. {
  152. struct Window *window;
  153.  
  154. if (AppPort = IExec->AllocSysObjectTags(ASOT_PORT, TAG_DONE))
  155. {
  156. win = make_window();
  157. if (window = (struct Window*)IIntuition->IDoMethod(win, WM_OPEN))
  158. {
  159. uint32
  160. sigmask = 0,
  161. siggot = 0,
  162. result = 0;
  163. uint16
  164. code = 0;
  165. BOOL
  166. done = FALSE;
  167.  
  168. IIntuition->GetAttr(WINDOW_SigMask, win, &sigmask);
  169. while (!done)
  170. {
  171. siggot = IExec->Wait(sigmask | SIGBREAKF_CTRL_C);
  172. if (siggot & SIGBREAKF_CTRL_C) done = TRUE;
  173. while ((result = IIntuition->IDoMethod(win, WM_HANDLEINPUT, &code)))
  174. {
  175. switch(result & WMHI_CLASSMASK)
  176. {
  177. case WMHI_CLOSEWINDOW:
  178. done = TRUE;
  179. break;
  180. case WMHI_GADGETUP:
  181. switch (result & WMHI_GADGETMASK)
  182. {
  183. case OBJ_BUTTON:
  184. printf("BUTTON\n");
  185. IIntuition->SetAttrs(OBJ(OBJ_CLICKTAB_1),
  186. CLICKTAB_Current, 1,
  187. TAG_END);
  188. IIntuition->RefreshGadgets((struct Gadget *)OBJ(OBJ_CLICKTAB_1), window, NULL);
  189. break;
  190. case OBJ_QUIT:
  191. done=TRUE;
  192. break;
  193. }
  194. break;
  195. case WMHI_ICONIFY:
  196. if (IIntuition->IDoMethod(win, WM_ICONIFY)) window = NULL;
  197. break;
  198. case WMHI_UNICONIFY:
  199. window = (struct Window*)IIntuition->IDoMethod(win, WM_OPEN);
  200. break;
  201. }
  202. }
  203. }
  204. }
  205.  
  206. IIntuition->DisposeObject(win);
  207. IExec->FreeSysObject(ASOT_PORT, AppPort);
  208. }
  209. }
salass00
salass00's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2011-02-03 11:27
@alfkil Which clicktab is it

@alfkil

Which clicktab is it that you're trying to change with IIntuition->SetGadgetAttrs()? If it's the OBJ_CLICKTAB_2 one that's on a page you need to use ILayout->SetPageGadgetAttrs() instead (see page_gc.doc autodoc for details).

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
@salass00 No, I am trying to

@salass00

No, I am trying to set the OBJ_CLICKTAB_1, it is the child of a VLayoutObject.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
Does nobody have a working

Does nobody have a working example of how to change the current clicktab without graphics corruption??

salass00
salass00's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2011-02-03 11:27
@alfkil I've used clicktab

@alfkil

I've used clicktab in some of my programs but as far as I remember I haven't had any cause to write code to change which tab is the current one while the window is open yet.

thomas
thomas's picture
Offline
Last seen: 1 week 5 days ago
Joined: 2011-05-16 14:23
I just tried this: case

I just tried this:

  1. case OBJ_BUTTON:
  2. Printf("BUTTON\n");
  3. SetAttrs(OBJ(OBJ_CLICKTAB_1),
  4. CLICKTAB_Current, 1,
  5. TAG_END);
  6. DoMethod (win, WM_RETHINK);
  7. break;

and it works, at least on OS 3.9.

alfkil
alfkil's picture
Offline
Last seen: 4 months 1 week ago
Joined: 2011-05-10 22:02
@thomas THANK you, phew that

@thomas

THANK you, phew that was a relief :).

Log in or register to post comments