I had troubles trying to create buttons that worked when your mouse was lifted etc a while back. Thought Some people could use this code if they run into similar troubles.
`Globals For Our Mouse Update Function
Global LastMClick as Integer
Global MClick as Integer
Global ButtonState as String
Global LastMScroll as Integer
Global MScroll as Integer
Global ScrollState as String
Function UpdateMouse()
LastMClick=MClick
MClick=MouseClick()
LastMScroll=MScroll
MScroll=mousez()
`Mouse is not held Down
if MClick=0 and LastMClick=0 then ButtonState="NotPressed"
`LeftMouse is held Down
if MClick=1 and LastMClick=0 then ButtonState="LeftPressed"
`LeftMouse has just Been Pressed
if MClick=1 and LastMClick=1 then ButtonState="LeftHeld"
`LeftMouse has just been Lifted
if MClick=0 and LastMClick=1 then ButtonState="LeftLifted"
`RightMouse has just been Pressed
if MClick=2 and LastMClick=0 then ButtonState="RightPressed"
`RightMouse is held Down
if MClick=2 and LastMClick=2 then ButtonState="RightHeld"
`RightMouse has just been Lifted
if MClick=0 and LastMClick=2 then ButtonState="RightLifted"
`Scroll Wheel Has not Been Scrolled
if MScroll=LastMScroll then ScrollState="NotScrolled"
`Scroll Wheel has been scrolled Up
if MScroll>LastMScroll then ScrollState="ScrolledUp"
`Scroll Wheel has been scrolled Down
if MScroll<LastMScroll then ScrollState="ScrolledDown"
Endfunction
In theory, there is no difference between theory and practice. But, in practice, there is.