Opened 18 years ago
Closed 16 years ago
#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):
- Click button
- Click input field to move the focus away from button
- 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 , 18 years ago
comment:2 by , 18 years ago
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 , 18 years ago
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:
- Click button2
- Focus on input
- Press enter
- 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 , 18 years ago
| Owner: | set to |
|---|---|
| Status: | new → accepted |
comment:5 by , 18 years ago
| Severity: | None → Blocking |
|---|
comment:6 by , 18 years ago
| Milestone: | → 3.2.13.3 |
|---|---|
| Owner: | changed from to |
| Resolution: | → Fixed |
| Status: | accepted → closed |
Fixed in version: 3.2.13.3
comment:7 by , 18 years ago
| Milestone: | 3.2.13.3 |
|---|---|
| Resolution: | Fixed |
| Status: | closed → reopened |
comment:8 by , 18 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → accepted |
This is not fixed right and since I need it to block the release I'm re-opening.
comment:9 by , 18 years ago
| Severity: | Blocking → None |
|---|
comment:10 by , 16 years ago
| Resolution: | → Wont Fix |
|---|---|
| Status: | accepted → closed |
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).

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