Jump to content

Ampersand problem in GUI Buttons


Recommended Posts

Below is a test script that demonstrates a miss behavior of the ampersand in GUI buttons when the mouse is moved, either manually or via the MouseMove() function, and another GUI is then displayed. Specifically, the accelerator key underlines disappear if the mouse is moved in any way and another GUI, with accelerator keys, is displayed, even after deleting the previous GUI. To get them to display properly, immediately after GUISetState(@SW_SHOW) send Alt-Left-Shift.

Is this a bug, or am I overlooking a GUI procedure? If a bug, will someone please move the post to bug reports.

If you try the script, let it run without moving the mouse (the script will move the mouse) and it will close all GUI's and messages after 2 seconds and 5 seconds respectively.

#include <guiconstants.au3>

; Demonstrate the underlines display properly when mouse is not moved.
MsgBox(4096, "Test 1 thru 3", "DO NOT MOVE THE MOUSE." & @LF & "THIS MESSAGE LASTS 5 SECONDS." & @LF & "THE UNDERLINES ON THE GUI BUTTON NAMES WILL BE OKAY.", 5)
For $i = 1 to 3
    $GUI = GUICreate("TEST " & $i & " of 3", 350, 80)
    $l1 = GUICtrlCreateLabel("DO NOT MOVE THE MOUSE," & @lf & "UNDERLINES SHOW UNLESS MOUSE IS MOVED.", 10, 10, 340, 40)
    $b1 = GUICtrlCreateButton("&OK", 10, 50, 50, 20)
    $b2 = GUICtrlCreateButton("&Cancel", 80, 50, 50, 20)
    GUISetState(@SW_SHOW, $GUI)
    Sleep(2000)
    GUIDelete($GUI)
; no mouse movement performed here.
    Sleep(500)
Next

; Make the underlines disappear by moving the mouse.
MsgBox(4096, "Test 11 thru 13", "THIS MESSAGE LASTS 5 SECONDS." & @LF & "WHEN THE NEXT GUI APPEARS, THE MOUSE IS MOVED" & @LF & "AND THE UNDERLINES DISAPPEAR.", 5)
For $i = 11 to 13
    $GUI = GUICreate("TEST " & $i & " of 13", 350, 80)
    $l1 = GUICtrlCreateLabel("MOVING THE MOUSE," & @lf & "UNDERLINES DO NOT SHOW AFTER MOUSE IS MOVED.", 10, 10, 340, 40)
    $b1 = GUICtrlCreateButton("&OK", 10, 50, 50, 20)
    $b2 = GUICtrlCreateButton("&Cancel", 80, 50, 50, 20)
    GUISetState(@SW_SHOW, $GUI)
    Sleep(2000)
    GUIDelete($GUI)
    MouseMove(100, 100, 1); <<<<<<< This causes the underline to disappear
    Sleep(500)
Next

; The Work around (ALT-LEFT-SHIFT).
MsgBox(4096, "Test 21 thru 23", "THIS MESSAGE LASTS 5 SECONDS." & @LF & "WHEN THE NEXT GUI APPEARS, THE MOUSE IS MOVED" & @LF & "BUT ALT-LEFT-SHIFT IS SENT TO" & @LF & "FORCE THE UNDERLINES TO REMAIN.", 5)
For $i = 21 to 23
    $GUI = GUICreate("TEST " & $i & " of 23", 350, 80)
    $l1 = GUICtrlCreateLabel("MOVING THE MOUSE," & @lf & "UNDERLINES SHOULD SHOW ANYWAY BECAUSE OF !{LSHIFT}.", 10, 10, 340, 40)
    $b1 = GUICtrlCreateButton("&OK", 10, 50, 50, 20)
    $b2 = GUICtrlCreateButton("&Cancel", 80, 50, 50, 20)
    GUISetState(@SW_SHOW, $GUI)
    Send("!{LSHIFT}"); <<<<<<<<<<<<<<<<<<<< this SEEMS to fix the underline problem
    Sleep(2000)
    GUIDelete($GUI)
    MouseMove(100, 100, 1); <<<<<<< This causes the underline to disappear
    Sleep(500)
Next

Phillip

Link to post
Share on other sites

I couldn't replicate on Windows XP Pro SP2 with the latest AutoIt beta.

If running Windows XP, do you have it configured to always show the underlines or not?

<{POST_SNAPBACK}>

Well, that's interesting! The check box for "Hide underlined letters for keyboard navigation until I press the Alt key" was indeed checked. I unchecked it and re-ran the script and all is well. Thanks for the scoop.

Considering this Windows option, I wonder why, when the box is checked, the underscores ever show unless I would press the Alt key? Go figure.

Thanks again,

Phillip

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...