Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Overlay Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Overlay/Overlay Test
This example is the version from Sun, 10th Dec 2016.
Project "Overlay Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action()
updatebar
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
create
End EventHandler
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
EventHandler Sub Action()
if o<>Nil then
o.IgnoreMouseClicks=me.Value
end if
End EventHandler
End Control
Control CheckMove Inherits CheckBox
ControlInstance CheckMove Inherits CheckBox
End Control
EventHandler Function KeyDown(Key As String) As Boolean
Select case asc(key)
case 28 'left
move -10,0
Return true
case 29 'right
move 10,0
Return true
case 30 'top
move 0,-10
Return true
case 31 'down
move 0,10
Return true
end Select
End EventHandler
Sub Create()
p = new Picture(128,150,32)
dim pg as Graphics = p.Graphics
dim mg as Graphics = p.mask.Graphics
mg.ForeColor = &cFFFFFF
mg.FillRect 0, 0, p.Width, p.Height
pg.DrawPicture IconPict,0,0
mg.DrawPicture IconMask,0,0
o=new MyOverlay(500,100,128,150)
o.Pict = p
// use Mask from picture
o.Mask = nil
// explicit mask
o.Mask = p.mask
updatebar
o.Show
timer1.Mode=2
End Sub
Private Sub move(x as integer, y as integer)
o.Move o.Left+x,o.top+y
End Sub
Private Sub updatebar()
dim pos,w,r,i as integer
w=p.Width
p.mask.Graphics.ForeColor=&c000000
p.mask.Graphics.FillOval 0,130,w,20
p.Graphics.ForeColor=&c000000
counter=counter+4
pos=counter mod 512
for i=0 to w-1
pos=pos+4
pos=pos mod 512
if pos>255 then
r=511-pos
else
r=pos
end if
p.Graphics.ForeColor=rgb(r,0,0)
p.Graphics.DrawLine i,130,i,150
next
o.Update
End Sub
Property Private counter As Integer
Property Private o As MyOverlay
Property Private p As picture
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 IconMask
End ExternalFile
ExternalFile IconPict
End ExternalFile
Class MyOverlay Inherits OverlayMBS
EventHandler Function MouseDown(x as integer, y as integer, modifiers as integer) As boolean
log CurrentMethodName+" "+str(x)+" "+str(y)
End EventHandler
EventHandler Function MouseDragged(x as integer, y as integer, modifiers as integer) As boolean
if window1.CheckMove.Value then
log CurrentMethodName+" "+str(x)+" "+str(y)
end if
End EventHandler
EventHandler Sub MouseEnter(x as integer, y as integer, modifiers as integer)
log CurrentMethodName+" "+str(x)+" "+str(y)
End EventHandler
EventHandler Sub MouseExit(x as integer, y as integer, modifiers as integer)
log CurrentMethodName+" "+str(x)+" "+str(y)
End EventHandler
EventHandler Function MouseMoved(x as integer, y as integer, modifiers as integer) As boolean
if window1.CheckMove.Value then
log CurrentMethodName+" "+str(x)+" "+str(y)
end if
End EventHandler
EventHandler Function MouseUp(x as integer, y as integer, modifiers as integer) As boolean
log CurrentMethodName+" "+str(x)+" "+str(y)
End EventHandler
EventHandler Sub MouseWheel(x as integer, y as integer, dx as double, dy as double, modifiers as integer)
log CurrentMethodName+" "+str(x)+" "+str(y)+", delta "+str(dx)+"/"+str(dy)
End EventHandler
EventHandler Sub WindowBoundsChanged()
log "windowboundschanged"
End EventHandler
EventHandler Sub WindowClosed()
log "windowclosed"
End EventHandler
EventHandler Sub WindowHidden()
log "windowhidden"
End EventHandler
EventHandler Sub WindowShown()
log "windowShown"
End EventHandler
Private Function Window1open() As Boolean
dim i,c as integer
c=WindowCount-1
for i=0 to c
if window(i) isa window1 then
Return true
end if
next
End Function
Private Sub log(s as string)
System.DebugLog s
if Window1open then
window1.Listbox1.InsertRow 0,s
end if
End Sub
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Overlay Plugin.