Sign in to follow this  
Followers 0
blink314

Trouble with Labels and Events

12 posts in this topic

I'm trying to make a GUI and I've noticed that if I layer labels they do not respond to events. Run the sample I've attached. The left square is coded to generate an event (in this case a silly msgbox), but it does not generate an event. The right rectangle ONLY generates an event if you click on the part that is not on top of the other black label.

Any Ideas???

#include <GUIConstants.au3>

opt("GUIOnEventMode", 1) ; Change to OnEvent mod
$guiwidth = 200
$guiheight = 150
$MainGUi = GUICreate("Error Demo", $GUIWidth, $GUIHeight, @DesktopWidth/2-($guiwidth/2), @desktopheight/2-($GUIHeight/2+35), $WS_MINIMIZEBOX + $ws_maximizebox)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI")

;Left Box: Background label and top label
guictrlcreatelabel("Back",5,5,70,70)
GUICtrlSetBkColor(-1,0x000000)
guictrlcreatelabel("Front",6,6,68,68)
guictrlsetonevent(-1,"LabelClick")

;Right Box: Background label and top label
guictrlcreatelabel("Back",75,5,70,70)
GUICtrlSetBkColor(-1,0x000000)
guictrlcreatelabel("Front",76,6,100,68)
GUICtrlSetBkColor(-1,0xCCCCCC)
guictrlsetonevent(-1,"LabelClick")

GUISetState(@SW_SHOW)

While 1
    Sleep(1000) ; Idle around
WEnd

func LabelClick()
    msgbox(0,"","Click")
EndFunc

Func CloseGUI()
    Exit
EndFunc  ;==>CloseGUI

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this ... if the top one covers the bottom one where you can't click on it then ..... dunno

#include <GUIConstants.au3>

opt("GUIOnEventMode", 1) ; Change to OnEvent mod
$guiwidth = 200
$guiheight = 150
$MainGUi = GUICreate("Error Demo", $GUIWidth, $GUIHeight, -1, -1, $WS_MINIMIZEBOX + $ws_maximizebox)
GUISetOnEvent($GUI_EVENT_CLOSE, "CloseGUI")

;Left Box: Background label and top label
$BL = guictrlcreatelabel("Back",5,5,70,70)
GUICtrlSetBkColor(-1,0x000000)
$FL = guictrlcreatelabel("Front",16,16,68,68)
guictrlsetonevent($BL,"LabelClick")
guictrlsetonevent($FL,"LabelClick")

;Right Box: Background label and top label
$BR = guictrlcreatelabel("Back",75,5,70,70)
GUICtrlSetBkColor(-1,0x000000)
$FR = guictrlcreatelabel("Front",86,16,100,68)
GUICtrlSetBkColor(-1,0xCCCCCC)
guictrlsetonevent($BR,"LabelClick")
guictrlsetonevent($FR,"LabelClick")

GUISetState(@SW_SHOW)

While 1
    Sleep(1000) ; Idle around
WEnd

func LabelClick()
    msgbox(0,"","Click")
EndFunc

Func CloseGUI()
    Exit
EndFunc  ;==>CloseGUI
Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

Yours works how I would like mine to work. What did you change? Just the amount of overlap? I will need to have some topmost labels overlap the bottom label (to create a frame effect) so... I'll look at this more.

Kevin

Share this post


Link to post
Share on other sites

Oh, I see. You made the top and bottom labels have an event... I'll have to look into this. I may be able to make it work. The problem is the @GUI_CtrlId is all messed up!! Is this normal??

Kevin

Share this post


Link to post
Share on other sites

I don't see where you used @GUI_CtrlId.


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

Sorry. I changed the "Clicked" in the msgbox. If you do this, you get the ctrlid of the background label when click on the front label.

Kevin

Share this post


Link to post
Share on other sites

Try this and see if it helps ....

#include <GUIConstants.au3>

$Form1 = GUICreate("AForm1", 420, 182, -1, -1)
$BackLeft = GUICtrlCreateLabel("BackLeft", 48, 56, 100, 100)
GUICtrlSetBkColor(-1, 0x800000)
$BackRight = GUICtrlCreateLabel("BackRight", 224, 56, 100, 100)
GUICtrlSetBkColor(-1, 0x0000FF)
$FrontRight = GUICtrlCreateLabel("FrontRight", 280, 24, 100, 100)
GUICtrlSetBkColor(-1, 0xA6CAF0)
$FrontLeft = GUICtrlCreateLabel("FrontLeft", 96, 25, 100, 100)
GUICtrlSetBkColor(-1, 0xFF0000)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $BackLeft
            MsgBox(0,"","Back Left")
        Case $BackRight
            MsgBox(0,"","Back Right")
        Case $FrontLeft
            MsgBox(0,"","Front Left")
        Case $FrontRight
            MsgBox(0,"","Front Right")
    EndSwitch
WEnd

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

If I click on the front left label in the area where it overlaps with back left, the msgbox tells me back left was clicked... hmmmmmmmm

Kevin

Share this post


Link to post
Share on other sites

That's odd ..... :whistle:


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

It's like there is no sense of z-order, front/back, etc.

Kevin

Share this post


Link to post
Share on other sites

Bumpity bump bump.

Should this be a bug report or is there already a known solution ?


Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites

I havent seen anything while searching the forum. I posted in the bug area but now cant find my post. Personally, I think it's a bug, but I've managed to work around it in the script I'm writing. I wonder, though, if there are other z-order programs with GUI controls. Thanks for the sanity check fossil rock... when I first had this problem I thought I was waaaaaay off base.

Kevin

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  
Followers 0