Jump to content
Sign in to follow this  
sherkas

Onevent For Label Clicking?

Recommended Posts

sherkas

Im trying to have a GUI with 32 labels (looks like backpack slots for a game)

Is it possible to have a onevent for when they click one?

Basically I have 40 backpack slots that are labels that look white.

When they click one, I want it to update some fields and when they hit a button turn that label a different color.

I cant seem to get the onevent to register the click, nor find a way to make it so I can find out what label they clicked.

I tried

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")

And set

$slot[0] = GuiCtrlCreateLabel("1.1", 20, 20, 20, 20)

But whenever I click on my GUI it never accesses the functoin Clicked...

What do I do?

Share this post


Link to post
Share on other sites
GaryFrost

Im trying to have a GUI with 32 labels (looks like backpack slots for a game)

Is it possible to have a onevent for when they click one?

Basically I have 40 backpack slots that are labels that look white.

When they click one, I want it to update some fields and when they hit a button turn that label a different color.

I cant seem to get the onevent to register the click, nor find a way to make it so I can find out what label they clicked.

I tried

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")

And set

$slot[0] = GuiCtrlCreateLabel("1.1", 20, 20, 20, 20)

But whenever I click on my GUI it never accesses the functoin Clicked...

What do I do?

Supply a script the runs to show what you have that isn't working for you, you'll get better help that way.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
sherkas

Basically the function clicked is never ran.

I cant seem to get any onevents to work actually.

#include <GuiConstants.au3>

AutoItSetOption ( "GUIOnEventMode", 1 )

Dim $slot[32];Slots 0-31 = 32 slots

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")

; GUI
GuiCreate("Stall Moniter", 500, 300)
GuiSetIcon(@SystemDir & "\mspaint.exe", 0)

$slot[0] = GuiCtrlCreateLabel("1.1", 20, 20, 20, 20)
GuiCtrlSetBkColor(-1, 0xFFFFFF )

GUISetState (@SW_SHOW) 

Do
 Sleep( 1000 )
While 1 = 1

Func Clicked()

GUICtrlSetBkColor ( $slot[0], 0xFF0000 )  

EndFunc
Edited by sherkas

Share this post


Link to post
Share on other sites
GaryFrost

#include <GuiConstants.au3>

AutoItSetOption("GUIOnEventMode", 1)

Dim $slot[32];Slots 0-31 = 32 slots


; GUI
GUICreate("Stall Moniter", 500, 300)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")
GUISetIcon(@SystemDir & "\mspaint.exe", 0)

$slot[0] = GUICtrlCreateLabel("1.1", 20, 20, 20, 20)
GUICtrlSetBkColor(-1, 0xFFFFFF)

GUISetState(@SW_SHOW)

While 1
    Sleep(200)
WEnd

Func Clicked()
    
    GUICtrlSetBkColor($slot[0], 0xFF0000)
    
EndFunc  ;==>Clicked


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites
sherkas

heh look at that!

What was wrong? I assume I need to have the script looping fairly fast to catch it?

Share this post


Link to post
Share on other sites
GaryFrost

heh look at that!

What was wrong? I assume I need to have the script looping fairly fast to catch it?

look where the

GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Clicked")

line is


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.