Jump to content

Recommended Posts

Posted (edited)

Hello, all, i have met 1 small problem, AGAIN.

So here is my problem... I just want to make a button which image would change abit after pressing it. All was OK, but later i had noticed, that after i press any button once it becomes "selected" (you may see special borders) and if i want to press other button and see same "selection" efect (you cant see special borders), i need to press other buttom 2 times to remove "selection" efect from previous button and use it on 2nd.

With 1st button you just change image in button and 2nd one is just a test button, to see what i am talking about.

Here is my code, it may be easyer to understand what did i mean:

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>

Opt("GUIOnEventMode", 1)

$RedLight = @ScriptDir & "\Image\RedLight.bmp"
$GreenLight = @ScriptDir & "\Image\GreenLight.bmp"
GuiCreate("Test",400,400)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
$Button = GUICtrlCreateButton("1", 87, 42, 83, 25)
$ButtonList = _GUIImageList_Create(18, 18, 5, 3)
_GUIImageList_AddBitmap($ButtonList, $RedLight)
_GUICtrlButton_SetImageList($Button, $ButtonList,0,4,1,1,2) 
GUICtrlSetOnEvent($Button, "_Button1")
$Button2 = GUICtrlCreateButton("2", 175, 42, 83, 25)
$ButtonList2 = _GUIImageList_Create(18, 18, 5, 3)
_GUIImageList_AddBitmap($ButtonList2, $RedLight)
_GUICtrlButton_SetImageList($Button2, $ButtonList2,0,4,1,1,2) 
GUICtrlSetOnEvent($Button2, "_Button2")
$data = GuiCtrlCreateInput("sss",10,10)
GUISetState(@SW_Show)

While 1
    sleep(50)
WEnd

Func _Button1()
$ButtonList = _GUIImageList_Create(18, 18, 5, 3)
_GUIImageList_AddBitmap($ButtonList, $GreenLight)
_GUICtrlButton_SetImageList($Button, $ButtonList,0,4,1,1,2) 
GuiCtrlSetData($data, "aaaaa")
EndFunc
Func _Exit()
    Exit
EndFunc
Edited by Makaule
  • Moderators
Posted

Makaule,

If I understand you correctly, I believe your problem will be solved by moving the focus away from the button once you have pressed it. You need to add a line to your _Button1 function like this:

GUICtrlSetData($data, "aaaaa")
ControlFocus("Test", "", $data)

Does that work for you? It certainly changes the behaviour of the buttons for me. :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

Thanks, i were looking for something like that, but problem was that i were trying to find it in Buttom Options :(

Thanks, Melba, Problem solved.

By The way, its also possible to solve my problem using _GUICtrlButton_SetFocus

Edited by Makaule

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...