LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

menubar shortcut not functional if focus is on string control

Solved!
Go to solution

Dear All,

 

I am wondering if this is the expected behavior or if I am doing something wrong:

 

On a panel I have a string control; on double clicking I open a file select box to select a file, the file name then is displayed on this string control. After this action, this string control is the active control, indicated by the grey frame.

 

I also have a menu bar with some shortcut keys defined, such as F2. It appears that F2 is not functional as long as the  focus is on the string control. This is inconvenient because a typical user action is selecting a file and then pressing Fx. To solve this problem the user needs to click somewhere on the panel to move the focus to another control. Of course this could be done programmatically, but this extra effort is not necessary say for ring controls or numeric controls. Also in numeric controls I can change the numbers, but even if a numeric control is the acitve control because of editing the value F2 immediately works.

 

Help is appreciated.

 

Thanks,

 

Wolfgang

0 Kudos
Message 1 of 8
(3,556 Views)

I just tried in a project of mine and had no problems in calling a menu function with its shortcut key while the focus is on a string control with a callback attached: maybe the problem lies in the string control callback, which is possibly trapping the keypress event before it is sent to the panel.

I tested both with "regular" shortcut keys (such as Ctrl + P) and with F2 only as the shortcat. My callback is not trapping EVENT_KEYPRESS event.

 

EDIT: I tried by swallowing keyboard presses with     if (event == EVENT_KEYPRESS) return 1;  but I am still able to operate on menus with shortcut keys. Seems the reason lies elsewhere: you can try progressively excluding parts of control callback and see when menus return responsive.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 8
(3,555 Views)

Thanks Roberto, I'll have a closer look...

0 Kudos
Message 3 of 8
(3,553 Views)

Added details:

 

1) The problem is not when the focus is on the string control in general, only after a text has been displayed on the string control. If the string control is empty but selected F2 works as expected. 

 

2) Here is the control callback, seems harmless...

 

    if ( event == EVENT_LEFT_DOUBLE_CLICK )
    {
        if ( SelectResultFile () && !save_results )
        {
            header_line = FALSE;
            save_results = TRUE;
            UtilitySetMenuItemChecked ( menubar_handle, MENUBAR_MENU1_ITEM1_13, save_results );
        }
    }
    return ( 0 );

The function SelectResultFile seems harmless, too... It calls FileSelectPopup; if a file was selected, it displays the file name on the string control and opens the file for writing.

0 Kudos
Message 4 of 8
(3,547 Views)
Solution
Accepted by topic author Wolfgang

I think what is happening here is that left double-click is also used to highlight text. So when you trigger the EVENT_LEFT_DOUBLE_CLICK, you are placing the text in the string control and then also highlighting it. There seems to be some strange behavior when the two of these happens at the same time because of the order of the events. You can see that moving the mouse around when returning from the file select popup causes the highlighting region to drag across the text. While in this highlighting mode, you cannot use the shortcuts for the menu. I was able to fix this by swallowing the EVENT_LEFT_DOUBLE_CLICK after setting the value of the control. 

National Instruments
Message 5 of 8
(3,531 Views)

It also seems as if this only happens when you select the file by clicking the Load/Select/Open button. If you select it by double-clicking the file name, it doesn't seem to happen.

 

We've created bug ID 349930 to track this.

 

Luis

Message 6 of 8
(3,526 Views)

Hi Darren,

 

Thanks a lot for looking into it!! Your diagnosis of the 'highlighting mode' is correct and also your suggested workaround. Very useful, indeed!

 

Hi Luis,

 

this sounds really intricate - actually I never double clicked a file because in this application one is selecting a result file, whicht typically doesn't exist yet.. Thanks for the CAR, too.

 

To summarize: Thank you all Smiley Very Happy

 

Wolfgang

0 Kudos
Message 7 of 8
(3,519 Views)

I am happy to see that this bug has been fixed in CVI2012 Smiley Happy

0 Kudos
Message 8 of 8
(3,485 Views)