Sign in to follow this  
Followers 0
treacheroust

Only part of my buttons are clickable

3 posts in this topic

The code below is working, except most of the buttons don't work. I have two buttons "snap" and "calibrate". If I hover over the left side of the "snap" button the button highlights - but the right side it doesn't work. The "calibrate" button is worst. It never highlights, I can't click it! Any help would be appreciated. This is my first attempt at a GUI. Thanks!

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Local $gui_yInc = 25
Local $gui_width = 300
Opt("GUIOnEventMode", 1)

Local $ctrl
Local $yCur = 0

GUICreate("Draft Helper", $gui_width, 4*$gui_yInc, 1200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

$ctrl = GUICtrlCreateLabel("Card", 0, $yCur, $gui_width/4, $gui_yInc)
GUICtrlSetFont($ctrl, 8.5, 800)
$ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

$ctrl = GUICtrlCreateLabel("Rating", 0, $yCur, $gui_width/4, $gui_yInc)
GUICtrlSetFont($ctrl, 8.5, 800)
$ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

$ctrl = GUICtrlCreateLabel("Notes", 0, $yCur, $gui_width/4, $gui_yInc)
GUICtrlSetFont($ctrl, 8.5, 800) 
$ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

$ctrl = GUICtrlCreateButton("Snap",  0, $yCur, $gui_width/2, $gui_yInc)
GUICtrlSetOnEvent($ctrl, "SNAPButton")
$ctrl = GUICtrlCreateButton("Calibrate",  $gui_width/2, $yCur, $gui_width/2, $gui_yInc)
GUICtrlSetOnEvent($ctrl, "CALIBRATEButton")
$yCur += $gui_yInc
GUISetState(@SW_SHOW)

Func CLOSEClicked()
  Exit
EndFunc

Func SNAPButton()
  MsgBox(0, 'Testing', 'Snap')
EndFunc

Func CALIBRATEButton()
  MsgBox(0, 'Testing', 'Cal')
EndFunc

While (1)
    Sleep(100)
WEnd

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Your labels probably overlap your buttons.

Try to comment GUICtrlCreateLabel() commands and look if buttons will work.

EDIT:

This works fine

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Local $gui_yInc = 25
Local $gui_width = 300
Opt("GUIOnEventMode", 1)

Local $ctrl
Local $yCur = 0

GUICreate("Draft Helper", $gui_width, 4*$gui_yInc, 1200, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

;~ $ctrl = GUICtrlCreateLabel("Card", 0, $yCur, $gui_width/4, $gui_yInc)
;~ GUICtrlSetFont($ctrl, 8.5, 800)
;~ $ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

;~ $ctrl = GUICtrlCreateLabel("Rating", 0, $yCur, $gui_width/4, $gui_yInc)
;~ GUICtrlSetFont($ctrl, 8.5, 800)
;~ $ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

;~ $ctrl = GUICtrlCreateLabel("Notes", 0, $yCur, $gui_width/4, $gui_yInc)
;~ GUICtrlSetFont($ctrl, 8.5, 800) 
;~ $ctrl = GUICtrlCreateLabel("", $gui_width/4, $yCur, $gui_width*3/4, $yCur)
$yCur += $gui_yInc

$ctrl1 = GUICtrlCreateButton("Snap",  0, $yCur, $gui_width/2, $gui_yInc)
GUICtrlSetOnEvent($ctrl1, "SNAPButton")
$ctrl2 = GUICtrlCreateButton("Calibrate",  $gui_width/2, $yCur, $gui_width/2, $gui_yInc)
GUICtrlSetOnEvent($ctrl2, "CALIBRATEButton")
;~ $yCur += $gui_yInc
GUISetState(@SW_SHOW)

Func CLOSEClicked()
  Exit
EndFunc

Func SNAPButton()
  MsgBox(0, 'Testing', 'Snap')
EndFunc

Func CALIBRATEButton()
  MsgBox(0, 'Testing', 'Cal')
EndFunc

While (1)
    Sleep(100)
WEnd
  Edited by Zedna

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you very much! You're right! I was setting the label height wrong, so they were too tall and overlapped the buttons.

Edited by treacheroust

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