Modify

Opened 2 years ago

Closed 2 years ago

#3854 closed Bug (Wont Fix)

Setting Control Color has unintended consequences in GUI

Reported by: paul.keselman@… Owned by:
Milestone: Component: AutoIt
Version: 3.3.14.5 Severity: None
Keywords: Cc:

Description (last modified by mLipok)

Uncommenting GUICtrlSetColor creates a bug where interacting with the input, also causes the button function to be executed

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 200, 100)
$hButton = GUICtrlCreateButton("Button", 10, 10, 160, 24)
;GUICtrlSetColor($hButton, 0xFF0000)
$hInput = GUICtrlCreateInput("", 10, 40, 60, 24)
GUISetState()

While 1
   Switch GUIGetMsg()
          Case $hButton
                 ConsoleWrite("Button" & @CR)
          Case $hInput
                 ConsoleWrite("Input" & @CR)
          Case $GUI_EVENT_CLOSE
                 Exit
   EndSwitch
WEnd

Attachments (0)

Change History (5)

comment:1 Changed 2 years ago by paul.keselman@…

There is a bug in my code. Please change
GUICtrlSetColor($hConnectionButton, 0xFF0000)
to
GUICtrlSetColor($hButton, 0xFF0000)

comment:2 Changed 2 years ago by Jos

  • Description modified (diff)

I updated the code in the original post but don't understand what your issues is you are trying to report here. I have the impression the code works the same with or without that line?
Or do you mean when you type something in the input field and hit enter after which both events fire?

Last edited 2 years ago by Jos (previous) (diff)

comment:3 Changed 2 years ago by Jos

It seems that the GUICTRLSetColor() also sets the focus to the button.
This works fine:

#include <GUIConstantsEx.au3>
$hGUI = GUICreate("Test", 200, 100)
$hButton = GUICtrlCreateButton("Button", 10, 10, 160, 24)
GUICtrlSetColor($hButton, 0xFF0000)
$hInput = GUICtrlCreateInput("", 10, 40, 60, 24)
GUICtrlSetState($hInput, $GUI_FOCUS)
GUISetState()
While 1
	Switch GUIGetMsg()
		Case $hButton
			ConsoleWrite("Button" & @CR)
		Case $hInput
			ConsoleWrite("Input" & @CR)
		Case $GUI_EVENT_CLOSE
			Exit
	EndSwitch
WEnd

Not sure whether this is intended or a bug.

Last edited 2 years ago by Jos (previous) (diff)

comment:4 Changed 2 years ago by mLipok

  • Description modified (diff)

comment:5 Changed 2 years ago by Melba23

  • Resolution set to Wont Fix
  • Status changed from new to closed

This is a known bug with colouring buttons - see https://www.autoitscript.com/trac/autoit/ticket/376

As you can see it cannot/will not be fixed, so I suggest not colouring your buttons.

M23

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 ticket will remain with no owner.
Author


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

 
Note: See TracTickets for help on using tickets.