/lib/CButtonControl.ahk

http://github.com/Skiouros/Macro · AutoHotKey · 39 lines · 20 code · 1 blank · 18 comment · 0 complexity · 54ecfd78f9e9f6689feadd0f94cf9096 MD5 · raw file

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