PageRenderTime 16ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/CButtonControl.ahk

http://github.com/Skiouros/Macro
AutoHotKey | 39 lines | 20 code | 1 blank | 18 comment | 0 complexity | 54ecfd78f9e9f6689feadd0f94cf9096 MD5 | raw file
 1/*
 2Class: CButtonControl
 3A button control.
 4
 5This control extends <CControl>. All basic properties and functions are implemented and documented in this class.
 6*/
 7Class CButtonControl Extends CControl
 8{
 9	__New(Name, Options, Text, GUINum)
10	{
11		Options .= " +0x4000" ;BS_NOTIFY to allow receiving BN_SETFOCUS and BN_KILLFOCUS notifications in CGUI
12		Base.__New(Name, Options, Text, GUINum)
13		this.Type := "Button"
14		this._.Insert("ControlStyles", {Center : 0x300, Left : 0x100, Right : 0x200, Default : 0x1, Wrap : 0x2000, Flat : 0x8000})
15		this._.Insert("Events", ["Click"])
16		this._.Insert("Messages", {7 : "KillFocus", 6 : "SetFocus" }) ;Used for automatically registering message callbacks
17	}	
18	
19	PostCreate()
20	{
21		this.Style := "+0x4000" ;BS_NOTIFY to allow receiving BN_SETFOCUS and BN_KILLFOCUS notifications in CGUI
22	}
23	/*
24	Event: Introduction
25	To handle control events you need to create a function with this naming scheme in your window class: ControlName_EventName(params)
26	The parameters depend on the event and there may not be params at all in some cases.
27	Additionally it is required to create a label with this naming scheme: GUIName_ControlName
28	GUIName is the name of the window class that extends CGUI. The label simply needs to call CGUI.HandleEvent(). 
29	For better readability labels may be chained since they all execute the same code.
30	Instead of using ControlName_EventName() you may also call <CControl.RegisterEvent> on a control instance to register a different event function name.
31	
32	Event: Click()
33	Invoked when the user clicked on the button.
34	*/
35	HandleEvent(Event)
36	{
37		this.CallEvent("Click")
38	}
39}