Sign in to follow this  
Followers 0

Wrong button getting DEFBUTTON status when readonly input used.

9 posts in this topic

Posted

It appears that when an input control before a button has the readonly style, the following button becomes the default button ($GUI_DEFBUTTON), regardless of whether you set the default button to something else or not. So I made this repro script to demonstrate the problem I'm seeing.

#include <GUIConstants.au3>
Func _TestGUI($bShowBug)
    $iStyle = $GUI_SS_DEFAULT_INPUT
    If $bShowBug Then
        $iStyle = BitOR($iStyle, $ES_READONLY)
    EndIf
    GUICreate(@AutoItVersion, 225, 60)
    GUICtrlCreateInput('Readonly Input', 5, 5, 100, 20, $iStyle)
    GUICtrlCreateButton('Button 1', 120, 5, 100, 20)
    GUICtrlCreateInput('Input', 5, 35, 100, 20)
    GUICtrlCreateButton('Button 2', 120, 35, 100, 20)
        GUICtrlSetState(-1, $GUI_DEFBUTTON)
    GUISetState()
    
    Do
        ;
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc

MsgBox(0x40, 'Normal/Expected Behaviour', 'In the following dialog, press the tab key to cycle through controls.' & @LF & _
    'You''ll see that unless Button 1 has focus, Button 2 is always the default' & @LF & _
    'button. Close the window to continue.')

_TestGUI(0)

MsgBox(0x40, 'Buggy/Unexpected Behaviour', 'But in the following dialog, press the tab key to cycle through controls' & @LF & _
    'and you''ll see that unless Button 2 has focus, Button 1 has become the default' & @LF & _
    'button, even though the script explicitly set Button 2 as default.')

_TestGUI(1)

I tested the most recent version (3.2.8.1), and the oldest available version (3.2.5.0), although none in between.

Share this post


Link to post
Share on other sites



Posted (edited)

It appears that when an input control before a button has the readonly style, the following button becomes the default button

Hm.. it seems that even not ReadOnly Input make this bug(?)...

#include <GUIConstants.au3>

GUICreate(@AutoItVersion, 225, 60)

$Button1 = GUICtrlCreateButton('Button 1', 120, 5, 100, 20)
$Button2 = GUICtrlCreateButton('Button 2', 120, 35, 100, 20)

GUICtrlCreateInput('Input', 5, 5, 100, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            MsgBox(0, "", "Button1 Pressed", 3)
        Case $Button2
            MsgBox(0, "", "Button2 Pressed", 3)
    EndSwitch
WEndoÝ÷ Ø    ݶ¢×«²Ø§)Ú[aȬ¶­Â§Ê©­ë,ÔÄE×jémnëm¢x¬¦·¬±çZØ­mçéèàz·^}«¥µ»­¶ÛºÛazxÊ'$¢{ay»­¶â·lmçç^}«¥µ¨p'tÖ¶¬ªizwpØZW(ÚèØZµÆ¦y§íz¶î¶Ú'r·¶*'~éÜjëh×6#include <GUIConstants.au3>

GUICreate(@AutoItVersion, 225, 60)

$Button = GUICtrlCreateButton('Button', 120, 5, 100, 20)
GUICtrlCreateRadio('Radio', 5, 5, 100, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button
            MsgBox(0, "", "Button Pressed", 3)
    EndSwitch
WEnd

P.S

Tested on AutoIt 3.2.4.9

Edited by MsCreatoR

Share this post


Link to post
Share on other sites

Posted (edited)

Just a comment on this, Windows doesn't do the right thing regarding default push-button behavior. What you are seeing is my own custom implementation which exists for other reasons but also attempts to address some of the issues Windows has. I don't rule out that there are bugs in my implementation. Maybe someday before some of us die I'll take a look at this but don't hold your breath.

Edit: Just to be clear, I AM NOT saying this is a bug in Windows. My point was, default push-button stuff is tricky to get right, so there's pretty much always going to be a corner case somewhere.

Edited by Valik

Share this post


Link to post
Share on other sites

Posted

Just a comment on this, Windows doesn't do the right thing regarding default push-button behavior. What you are seeing is my own custom implementation which exists for other reasons but also attempts to address some of the issues Windows has. I don't rule out that there are bugs in my implementation. Maybe someday before some of us die I'll take a look at this but don't hold your breath.

Edit: Just to be clear, I AM NOT saying this is a bug in Windows. My point was, default push-button stuff is tricky to get right, so there's pretty much always going to be a corner case somewhere.

Glad to see you. :)

I am trying to fix some behavior . I think I did a good job but a not complete one. stay tune you will get what I did very soon.

Share this post


Link to post
Share on other sites

Posted

I try my best ( at least I hope) it was pretty hard ... <_<

Fixed 3.2.9.4

Share this post


Link to post
Share on other sites

Posted

I just now re-tested this and unfortunately it's still not working properly. <_<

Sorry jp, I don't want to whine about it, but I didn't think it right to let this bug report say it was fixed when it's not.

If you try my example code I provided in the first post in this thread, you'll see that whenever any button gets and then loses focus, the default button gets completely unset, so no button gets default status.

Sorry to rain on your hard work. :) Thanks for trying though.

Share this post


Link to post
Share on other sites

Posted

I just now re-tested this and unfortunately it's still not working properly. <_<

Sorry jp, I don't want to whine about it, but I didn't think it right to let this bug report say it was fixed when it's not.

If you try my example code I provided in the first post in this thread, you'll see that whenever any button gets and then loses focus, the default button gets completely unset, so no button gets default status.

Sorry to rain on your hard work. :) Thanks for trying though.

That's the best I can do if a edit control get the focus then no button will keep the defpushbutton.

defpushbutton is only valid when starting after it will follow the focus.

I think that better than the previous sitation. It was very hard to reach this not so bad behavior. At least for me more coherent :P

Share this post


Link to post
Share on other sites

Posted

I'm re-opening this until I can confirm the the behavior and the fix.

Share this post


Link to post
Share on other sites

Posted

Fixed in 3.2.11.1.

1 person likes this

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.