Modify

#376 closed Bug (Wont Fix)

GUICtrlSetBkColor() causes button to catch enter key

Reported by: amokoura Owned by: Valik
Milestone: Component: AutoIt
Version: 3.2.12.0 Severity: None
Keywords: GUICtrlSetBkColor button color enter Cc:

Description

By using GUICtrlSetBkColor() on a button causes it to catch enter key.
Steps to reproduce (Run the code):

  1. Click button
  2. Click input field to move the focus away from button
  3. Press enter (button event happens)

If you comment out the coloring function, the button won't catch enters all by itself anymore.

#include <GUIConstants.au3>

GUICreate("Form1", 166, 89, 234, 191)
GUICtrlCreateInput("Input1", 16, 8, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 16, 40, 123, 25, 0)
GUISetState(@SW_SHOW)

GUICtrlSetBkColor($Button1, 0x00ff00)

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			MsgBox(0, "", "button triggered")
	EndSwitch
WEnd

Attachments (0)

Change History (10)

comment:1 by amokoura, on Jun 14, 2008 at 4:39:37 PM

Note: The bug doesn't exist in earlier AutoIt versions

comment:2 by Jon, on Jun 14, 2008 at 6:12:32 PM

You need to use $BS_DEFPUSHBUTTON to specify the default button, you were using 0.

#include <GUIConstants.au3>
#include <ButtonConstants.au3>

GUICreate("Form1", 166, 89, 234, 191)
GUICtrlCreateInput("Input1", 16, 8, 121, 21)
$Button1 = GUICtrlCreateButton("Button1", 16, 40, 123, 25, $BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW)

While 1
	Switch GUIGetMsg()
		Case $GUI_EVENT_CLOSE
			Exit
		Case $Button1
			MsgBox(0, "", "button triggered")
	EndSwitch
WEnd

However, using the BKColor functions seems to "make" it default which needs checking out...

comment:3 by amokoura, on Jun 15, 2008 at 9:41:50 AM

Yes coloring "steals" the default. Here's another example. There are two colored buttons. Other one is defined as default. Pressing enter in the input will trigger the button that was last clicked.
The steps:

  1. Click button2
  2. Focus on input
  3. Press enter
  4. Button2 event happens instead of Button1
    #include <GUIConstants.au3>
    #include <ButtonConstants.au3>
    
    GUICreate("Form1", 166, 150, 234, 250)
    GUICtrlCreateInput("Input1", 16, 8, 121, 21)
    $Button1 = GUICtrlCreateButton("Button1", 16, 40, 123, 25, $BS_DEFPUSHBUTTON)
    $Button2 = GUICtrlCreateButton("Button2", 16, 80, 123, 25)
    
    GUICtrlSetBkColor($Button1, 0x00ff00)
    GUICtrlSetBkColor($Button2, 0x00ff00)
    
    GUISetState(@SW_SHOW)
    
    
    
    While 1
    	Switch GUIGetMsg()
    		Case $GUI_EVENT_CLOSE
    			Exit
    		Case $Button1
    			MsgBox(0, "", "button1 triggered")
    		Case $Button2
    			MsgBox(0, "", "button2 triggered")
    	EndSwitch
    WEnd
    

comment:4 by Valik, on Jun 16, 2008 at 6:10:00 PM

Owner: set to Valik
Status: newaccepted

comment:5 by Valik, on Jun 16, 2008 at 7:31:25 PM

Severity: NoneBlocking

comment:6 by J-Paul Mesnage, on Jun 17, 2008 at 11:23:56 AM

Milestone: 3.2.13.3
Owner: changed from Valik to J-Paul Mesnage
Resolution: Fixed
Status: acceptedclosed

Fixed in version: 3.2.13.3

comment:7 by Valik, on Jun 17, 2008 at 4:23:20 PM

Milestone: 3.2.13.3
Resolution: Fixed
Status: closedreopened

comment:8 by Valik, on Jun 17, 2008 at 4:24:23 PM

Owner: changed from J-Paul Mesnage to Valik
Status: reopenedaccepted

This is not fixed right and since I need it to block the release I'm re-opening.

comment:9 by Valik, on Jul 30, 2008 at 4:07:00 PM

Severity: BlockingNone

comment:10 by Valik, on Oct 22, 2009 at 1:24:32 AM

Resolution: Wont Fix
Status: acceptedclosed

I'm just going to set this as won't fix. I do not agree with any way to fix this short of writing the GUI from scratch and not even including custom colors (it should have never been built-in in the first place).

Modify Ticket

Action
as closed The owner will remain Valik.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.