23 September 2016, 05:33 | #1 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
GadTools ListView questions.
How do I get messages from a GadTools listview scroll bar and arrow keys? I have working code that allows selecting listview items with the cursor keys, but I can't get the scroll bar and arrow keys to send any messages.
|
23 September 2016, 10:41 | #2 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,377
|
I don't think the Listview gadget passes those messages on, but first make sure your window has WFLG_REPORTMOUSE set and you're looking for IDCMP_MOUSEMOVE and IDCMP_INTUITICKS as these are needed for reading scrollbars. If that doesn't pass the messages through to your window, perhaps you just need to poll the Listview every time you get an Intuiticks message and see what the GTLV_Top value is. Not ideal but it should work.
|
23 September 2016, 17:58 | #3 | |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
I think you may be right.
Quote:
Thanks |
|
23 September 2016, 19:10 | #4 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Anyone else have any ideas?
|
23 September 2016, 19:42 | #5 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Solved it. You can just calculate the top item from the selected item and the mouse position.
|
24 September 2016, 17:52 | #6 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,025
|
Why don't you use the GTLV_Top attribute?
|
24 September 2016, 19:48 | #7 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
Because I didn't find a way to read it (just did: GT_GetGadgetAttrs). It's not in the AOS2.x documentation (which is why I didn't find it at first), because it's 3.x, and since it's 3.x only, I'm not using it. This stuff should just work on 2.x too.
Last edited by Thorham; 24 September 2016 at 20:19. |
25 September 2016, 09:50 | #8 |
Registered User
Join Date: Oct 2012
Location: Germany
Posts: 585
|
Hm, it's your decision, but nowadays ppl seem to have either 3.x or 1.3. Except for some A600s with soldered kick 2.x.
|
25 September 2016, 21:06 | #9 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,831
|
While that's probably true, I see no reason to make this thing not work under 2.x, especially since it's written for use with FrexxEd, which is 2.x compatible.
|
28 March 2021, 01:31 | #10 |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Another LISTVIEW GADGET question. I have created listview and filled it with some data.. but I can't select anything or even scroll, the scroll bar works itself, but not scrolling the content..
I noticed that listview getting the messages, for example I can close the application if I click on the listview.. here is my code: Also I spent a lot of time, because nothis was showing in the listview, until I refreshed the window after creation.. Code:
int APP_Init_Window() { if (!(APP_pubscreen = LockPubScreen(NULL))) return 0; APP_visual_info = GetVisualInfo(APP_pubscreen, TAG_DONE); // get some helpers to create more compact window ULONG font_width = APP_pubscreen->RastPort.TxWidth;; ULONG font_height = APP_pubscreen->RastPort.TxHeight; ULONG win_pos_x = APP_pubscreen->Width / 2 - 320 / 2; ULONG win_pos_y = APP_pubscreen->Height / 2 - 240 / 2; struct Gadget* g_context; struct Gadget* g_list_modes; g_context = CreateContext (&APP_g_list); struct List *DaList; char *BassSpaces[] = {"Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", "Grass", "Eat", "Cows", "All", NULL}; struct Node *DaListNode; if (DaList = AllocMem (sizeof (struct List), MEMF_FAST)) { NewList (DaList); for (int i = 0; BassSpaces[i] != NULL; i++) { if (DaListNode = AllocMem(sizeof(struct Node), MEMF_FAST) ) { DaListNode->ln_Name = BassSpaces[i]; DaListNode->ln_Type = 100L; DaListNode->ln_Pri = 0; AddTail (DaList, DaListNode); } else { printf ("Could not allocate memory for node\n"); } } } else { printf ("Could not allocate memory for list\n"); } struct NewGadget ng; ng.ng_TextAttr = APP_pubscreen->Font; ng.ng_VisualInfo = APP_visual_info; ng.ng_LeftEdge = 10; ng.ng_TopEdge = font_height + 30; ng.ng_Width = 300; ng.ng_Height = 150; ng.ng_GadgetText = (STRPTR)"Please select your screen resolution..."; ng.ng_GadgetID = G_ID_LIST_MODES; ng.ng_Flags = 0; g_list_modes = g_context = CreateGadget (LISTVIEW_KIND, g_context, &ng, GTLV_ShowSelected, NULL, GTLV_Selected, 0, GTLV_MakeVisible, 0, GTLV_Labels, DaList, TAG_END); // --- create window --- APP_window = OpenWindowTags( NULL, WA_Left, win_pos_x, WA_Top, win_pos_y, WA_Width, 320, WA_Height, 240, WA_Title, (ULONG)"Raycaster Launcher v01", WA_SmartRefresh, TRUE, WA_Flags, WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_ACTIVATE, WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_REFRESHWINDOW | BUTTONIDCMP | LISTVIEWIDCMP | IDCMP_GADGETDOWN | IDCMP_GADGETHELP | IDCMP_GADGETUP, WA_PubScreen, (ULONG)APP_pubscreen, WA_Gadgets, (ULONG)APP_g_list, TAG_END); GT_RefreshWindow (APP_window, NULL); <<<< WITHOUT THIS NOTHING APPEARS IN LISTVIEW // signals for event and messages APP_signals = 1L << APP_window->UserPort->mp_SigBit; return 1; } void APP_Message_Loop() { BOOL is_loop = TRUE; while(is_loop) { if(SetSignal(0L, APP_signals) & APP_signals) { struct IntuiMessage* imsg; while( imsg = (struct IntuiMessage *)GetMsg(APP_window->UserPort) ) { switch (imsg->Class) { case IDCMP_REFRESHWINDOW: GT_BeginRefresh (APP_window); GT_EndRefresh (APP_window, TRUE); break; case IDCMP_CLOSEWINDOW: is_loop = FALSE; break; case IDCMP_GADGETUP: { struct Gadget *tmp_gadget = (struct Gadget *) imsg->IAddress; switch (tmp_gadget->GadgetID) { case G_ID_BUTTON_START: is_loop = FALSE; break; case G_ID_LIST_MODES: break; } } break; } ReplyMsg((struct Message *)imsg); } } } } |
28 March 2021, 10:06 | #11 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,025
|
You have to use GT_GetIMsg instead of GetMsg and GT_ReplyIMsg instead of ReplyMsg in your message loop.
And somewhere im your program you should have a Wait(), otherwise your program is unsuitable for a multitasking environment. Once you use Wait() you can no longer use SetSignal. You have to use the return value of Wait() instead. |
28 March 2021, 15:47 | #12 | |
Registered User
Join Date: Jan 2020
Location: Poland
Posts: 181
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to change a gadtools button's text? | alkis | Coders. C/C++ | 15 | 26 April 2016 19:11 |
gadtools | zharn | Coders. C/C++ | 6 | 21 February 2014 20:26 |
How to build a ListView | AGS | Coders. General | 0 | 22 December 2013 23:48 |
A few questions | Muzer | project.ClassicWB | 10 | 12 September 2009 14:14 |
A few questions! | One1 | New to Emulation or Amiga scene | 2 | 30 October 2002 17:41 |
|
|