Modify

Opened 16 years ago

Closed 15 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):

  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 Changed 16 years ago by amokoura

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

comment:2 Changed 16 years ago by Jon

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 Changed 16 years ago by amokoura

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 Changed 16 years ago by Valik

  • Owner set to Valik
  • Status changed from new to accepted

comment:5 Changed 16 years ago by Valik

  • Severity changed from None to Blocking

comment:6 Changed 16 years ago by Jpm

  • Milestone set to 3.2.13.3
  • Owner changed from Valik to Jpm
  • Resolution set to Fixed
  • Status changed from accepted to closed

Fixed in version: 3.2.13.3

comment:7 Changed 16 years ago by Valik

  • Milestone 3.2.13.3 deleted
  • Resolution Fixed deleted
  • Status changed from closed to reopened

comment:8 Changed 16 years ago by Valik

  • Owner changed from Jpm to Valik
  • Status changed from reopened to accepted

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

comment:9 Changed 16 years ago by Valik

  • Severity changed from Blocking to None

comment:10 Changed 15 years ago by Valik

  • Resolution set to Wont Fix
  • Status changed from accepted to 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).

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Valik.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.