27 July 2021, 20:21 | #1 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Intuition On Click Event?
I have gone through the documentation and cannot understand what I am doing wrong. Hopefully someone can help.
I have a window with a list and a text field. I want the focus to remain always in the text field regardless where the user clicks. At first I thought of using IDCMP_INTUITICKS event and use ActivateGadget on each tick. However I was never much in love with the idea as this means calling ActivateGadget for the text field even when this is already in focus. I therefore opted to instead only call ActivateGadget when the list is clicked or when the window is clicked. I thought the easiest way to do this is to listen for the IDCMP_MOUSEBUTTONS event (SELECTDOWN). This does work when clicking on the window, but not when clicking in the window title bar or the list. So in addition to IDCMP_MOUSEBUTTONS I also listen to IDCMP_GADGETUP. When I receive the event I check if the event is for my list and if so I use ActivateGadget on the text field. This works for this list but ONLY WHEN the list actually has an entry in it. If the list is empty then no IDCMP_GADGETUP event is triggered. So far I have not found how to capture an on click event on the title bar. Does anyone have any idea how I can capture an on click event on the title bar and a list (when this is empty)? |
27 July 2021, 23:09 | #2 |
Registered User
Join Date: Jan 2002
Location: Germany
Posts: 7,026
|
Probably the only way to do this is to sub-class STRGCLASS and overload its GM_HANDLEINPUT method. When STRGCLASS decides to let go, change the return value to keep focus.
|
28 July 2021, 12:02 | #3 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,307
|
In general, I believe it is a bad idea to patronize the user. Thus, if the user decides to click somewhere else, for whatever reason, then the program should rather tolerate that.
|
28 July 2021, 16:08 | #4 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
To be honest I only meant to implement this logic in order to save the user from doing some extra clicks.
A clear example is when moving the window. Left as is, the user would move the window and then have to click on the text field to enter some text. What I wanted is that the user would not need to click on the text field after moving the window because he would see the focus is already on this. Same thing as when re-activating a window by clicking anywhere on it, user would need to then need to do another click on the text field to continue using the application. I know it is sugar candy but thought it would be a nice touch. Quote:
Would I need to use BOOPSI to be able to do this? |
|
28 July 2021, 17:51 | #5 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
As usally - I know nothing - but maybe this helps: open the input.device add a handler that handler checks input events for IECLASS_ACTIVEWINDOW signal your task or send a msg ... just guessing^^ |
|
28 July 2021, 18:17 | #6 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,307
|
Window activation as IDCMP exists, so there is certainly a possibility to activate a gadget when the user activates the window. That seems to be the most straight-forwared way of doing it. Some care should be taken if there are multiple string gadgets on the same window as then the input focus could potentially change.
A good principle to follow is "principle of least surprise", i.e. don't make any changes that have not been triggered by the user explicitly. |
28 July 2021, 18:26 | #7 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
maybe someone is able to track the last selected input gadget... |
|
30 July 2021, 17:17 | #8 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
I managed to achieve that with IDCMP_ACTIVEWINDOW. Now when user focus again on my window it immediately focuses the user on the single text field that I have.
With IDCMP_CHANGEWINDOW I managed to also keep the focus on the single text field when the window is moved. (In the future I should not judge an event by its name, thought this was triggered when user "changed" window). With the IDCMP_MOUSEBUTTONS I have the click on anywhere on the window not covered by a gadget. Documentation says that this is only issued if not used internally by Intuition so I do not see it as that bad. The only issue I have is with the list gadget. I cannot understand why when the list has no items it does not trigger the IDCMP_GADGETDOWN even (or IDCMP_GADGETUP). Quote:
|
|
30 July 2021, 18:21 | #9 |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
|
31 July 2021, 09:38 | #10 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,307
|
There is nothing to click on, so why should it register something? IDCMP events are created whenever a gadget changes state, but there is nothing to change here.
|
31 July 2021, 13:53 | #11 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Fair point.
Not sure what I can do to be honest at this point apart from leaving it as is. Other option is to add a dummy entry in the list when it is empty and than handle this case separate as part IDCMP_GADGETUP. Its a hack, but the only thing I can think of |
31 July 2021, 15:35 | #12 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
try setting the GadgetType to 0 if the list is empty, and restore the type once something is added. |
|
31 July 2021, 22:55 | #13 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,307
|
Quote:
Don't. The problem is that you try to achieve something that is not part of the user interface style the Os offers, so just don't force it. Other programs won't react this way either, so it is not expected to work this way anyhow. |
|
31 July 2021, 23:10 | #14 |
Registered User
Join Date: Mar 2018
Location: Hastings, New Zealand
Posts: 2,719
|
|
01 August 2021, 00:16 | #15 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Hmm.. interesting. I test this by using the following code in the whole loop;
Code:
printf("%x\n", msg->Class); I will obviously test how the application feels and if it feels unnatural (or confusing) I would remove this or make it switchable on/off from a configuration file. Last edited by Sim085; 01 August 2021 at 00:32. |
01 August 2021, 11:02 | #16 |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
I did put a condition on event 0x00f80ad4. Works. But not always
I am thinking of going to the IDCMP_INTUITICKS path again. However ideally I would like to first check if my search field is already active and only call the ActivateGadget on this field if this is not activated. But ... ... I cannot find any function to do that from here, or a way to achieve this with GT_GetGadgetAttrs as documented here. Last edited by Sim085; 01 August 2021 at 11:42. |
01 August 2021, 15:44 | #17 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
hm: gad->Flags & GFLG_SELECTED does not work for you? You could also call SetGadgetAttrsA with GFLG_SELECTED set... |
|
01 August 2021, 17:56 | #18 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,307
|
You are doing something wrong. How exactly do you retreive the message? Note that for gadtools, you need to use GT_GetIMsg(), not GetMsg(). Also, do you check the return code for GetMsg() for NULL? Note that you need to wait for a message to arrive (either Wait() or WaitPort()).
|
01 August 2021, 18:44 | #19 | |
Registered User
Join Date: Apr 2009
Location: N/A
Posts: 962
|
Yes that worked. I was under the impression that selected would need to be retrieved using GT_GetGadgetAttrs. I see this is a flag however not an attribute.
This is my code; Code:
/* Main Loop. */ while(run) { /* Wait for an event to happen. */ int w = Wait(search_onKeyPressSignal | 1L << window->UserPort->mp_SigBit); ... /* Get message data. */ msg = (struct IntuiMessage *)GT_GetIMsg(window->UserPort); if(msg->Class == IDCMP_CLOSEWINDOW){ ... } ... /* Close message. */ GT_ReplyIMsg(msg); } Anything else looks wrong? The f80ad4 signal is issued multiple times when I hold the mouse left button on the list gadget. But clicking multiple times some times did not trigger an event. Don't know if that helps. This is why I reverted back to using IDCMP_INTUITICKS. Also something else I noticed is that this event is issued even if I did not register for it. Quote:
Last edited by Sim085; 01 August 2021 at 19:37. |
|
01 August 2021, 19:23 | #20 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
looks good. The most OS friendly way to get a gadget event in empty listviews seems to be setting GTLV_Labels with a one entry list of an empty string. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
intuition questions | meynaf | Coders. System | 11 | 09 December 2020 11:27 |
Help needed for an Intuition event loop | thyslo | Coders. System | 8 | 29 October 2018 19:08 |
C Intuition Help | plasmab | Coders. General | 7 | 15 October 2018 09:05 |
ClassicWB MultiBoot Menu (right click/left click on boot) not working | DuaneL | project.ClassicWB | 9 | 13 September 2016 16:32 |
click click bloody click | Dave_wb | support.Hardware | 14 | 12 April 2005 09:31 |
|
|