Jump to content

Trouble with Labels and Events


 Share

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

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