Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Overlay/Controls/Button/Button without plugin
Function:
Required plugins for this example:
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Overlay/Controls/Button/Button without plugin
This example is the version from Thu, 16th Jan 2013.
Project "Button without plugin.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control ButtonMBS1 Inherits MyButton
ControlInstance ButtonMBS1 Inherits MyButton
EventHandler Sub Action(x as integer, y as integer) dim d as new date Title="Last click: "+d.LongTime End EventHandler
End Control
Control ButtonMBS2 Inherits MyButton
ControlInstance ButtonMBS2 Inherits MyButton
EventHandler Sub Action(x as integer, y as integer) dim d as new date Title="Last click: "+d.LongTime End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
ExternalFile MouseOver
End ExternalFile
ExternalFile Normal
End ExternalFile
ExternalFile Disabled
End ExternalFile
ExternalFile Pressed
End ExternalFile
ExternalFile Mask
End ExternalFile
ExternalFile xDisable
End ExternalFile
ExternalFile xNormal
End ExternalFile
ExternalFile xOver
End ExternalFile
ExternalFile xDown
End ExternalFile
Class MyButton Inherits Canvas
ComputedProperty Sticky As Boolean
Sub Set() mSticky = value update End Set
Sub Get() return mSticky End Get
End ComputedProperty
ComputedProperty Toggle As Boolean
Sub Set() mToggle = value update End Set
Sub Get() return mToggle End Get
End ComputedProperty
ComputedProperty Value As Boolean
Sub Set() mValue = value update End Set
Sub Get() return mValue End Get
End ComputedProperty
Event Action(x as integer, y as integer) End Event
Event MouseDown(x as integer, y as integer) End Event
Event MouseDrag(x as integer, y as integer) End Event
Event MouseEnter() End Event
Event MouseExit() End Event
Event MouseUp(x as integer, y as integer) End Event
EventHandler Sub Activate() active = true update End EventHandler
EventHandler Sub Deactivate() active = false update End EventHandler
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean pressed = true update RaiseEvent MouseDown(x,y) Return true End EventHandler
EventHandler Sub MouseDrag(X As Integer, Y As Integer) RaiseEvent MouseDrag(x,y) End EventHandler
EventHandler Sub MouseEnter() RaiseEvent MouseEnter MouseOver = true update End EventHandler
EventHandler Sub MouseExit() RaiseEvent MouseExit MouseOver = false update End EventHandler
EventHandler Sub MouseUp(X As Integer, Y As Integer) pressed = false update RaiseEvent MouseUp(x,y) RaiseEvent Action(x,y) End EventHandler
EventHandler Sub Open() active = true End EventHandler
Sub update() if active and enabled then if pressed then if mouseover and ImagePressedMouseOver <>nil then backdrop = ImagePressedMouseOver else backdrop = ImagePressed end if else // not pressed if MouseOver and ImageMouseOver<>nil then backdrop = ImageMouseOver else backdrop = ImageNormal end if end if else // disabled if pressed and ImagePressedDisabled<>nil then backdrop = ImagePressedDisabled else // not pressed backdrop = ImageDisabled end if end if End Sub
Note "Note"
We provide this example with Canvas for people as a base to modify it. You can modify this much easier than our plugin based ButtonMBS class. Greetings Christian Schmitz
Property ImageDisabled As Picture
Property ImageMouseOver As Picture
Property ImageNormal As Picture
Property ImagePressed As Picture
Property ImagePressedDisabled As Picture
Property ImagePressedMouseOver As Picture
Property Private MouseOver As Boolean
Property Private Pressed As Boolean
Property Private active As Boolean
Property Private mSticky As Boolean
Property Private mToggle As Boolean
Property Private mValue As Boolean
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS Overlay Plugin.




Links
MBS FileMaker Plugins