custom slider : mouseRelease & mouseUp not triggered
Posted: Tue Jan 19, 2016 3:07 pm
Hi,
I must be missing something here...
A group contains three objects with no script
the group script is below
the mouseUp and mouseRelease messages are not hadled consistently to say the least.
stack attached
Thanks...
Fred.
LC 7 stable
I must be missing something here...
A group contains three objects with no script
the group script is below
the mouseUp and mouseRelease messages are not hadled consistently to say the least.
stack attached
Thanks...
Fred.
LC 7 stable
Code: Select all
local sLeft, sRight
local sX, sY
on mouseDown pBtn
# the vertical position
put item 2 of the loc of grc "Axis" of me into sY
# left and right limits
put the left of grc "Axis" of me + (the width of btn "Thumb" of me / 2) into sLeft
put the right of grc "Axis" of me - (the width of btn "Thumb" of me / 2) into sRight
repeat while the mouse is down
lock screen
put item 1 of the mouseLoc into sX
# check against limits
if sX < sLeft then put sLeft into sX
if sX > sRight then put sRight into sX
# set thumb btn loc
set the loc of btn "Thumb" of me to sX, sY
set the text of fld "Label" of me to the uThumb of me -- for now
# set label fld loc
if sX < sLeft + (sRight - sLeft) / 2 then
set the left of fld "Label" of me to the right of btn "Thumb" of me
set the textAlign of fld "Label" of me to left
else
set the right of fld "Label" of me to the left of btn "Thumb" of me
set the textAlign of fld "Label" of me to right
end if
unlock screen
end repeat
pass mouseDown
end mouseDown
setProp uThumb pValue
# set normalized value
put item 2 of the loc grc "Axis" of me into sY
put the left of grc "Axis" of me into sLeft
put the right of grc "Axis" of me into sRight
put pValue * (sRight - sLeft) +sLeft into sX
set the loc of btn "Thumb" of me to sX, sY
pass uThumb
end uThumb
getProp uThumb
# get normalized value
return (sX - sLeft) / (sRight - sLeft)
end uThumb
-- I dont want to send the value untill I release the mouse button
-- but these seem to be triggered only once in a while...
on mouseUp pBtn
set the backColor of btn "Thumb" of me to black
wait for 0.3 sec
set the backColor of btn "Thumb" of me to white
answer "mouseUp"
pass mouseUp
end mouseUp
on mouseRelease pBtn
set the backColor of btn "Thumb" of me to black
wait for 0.3 sec
set the backColor of btn "Thumb" of me to white
answer "mouseRelease"
pass mouseRelease
end mouseRelease