How to enter a time of day
BNig
niggemann at uni-wh.de
Tue Feb 23 18:10:36 EST 2010
Hi Scott,
thank you very much for this beautiful layout and functionality.
I couldn't resist to fiddle with the sliders, I wanted them to push each
other so the user can push both and determine a start or stop time and
without releasing the mouse pushing the other to the desired start/stop
time. One click saved and I find it intuitive, maybe not everyone.
Well here is the code for your backgroundscript of the sliders.
watch out for linebreaks
----------------------
local allowDrag,tLimitsStart,tLimitsEnd,tInc
local baseLeft,baseRight,tInterval,tMyName,tOtherName
local tBtnSpaceFromCenter, W, tVslider
local tHDiff, tVDiff
on mouseEnter
put false into allowDrag
end mouseEnter
on mouseDown
put the clickloc into tClick
put the loc of me into tmyLoc
put item 1 of tmyLoc - item 1 of tClick into tHDiff
put item 2 of tmyLoc - item 2 of tClick into tVDiff
put short name of me into tInterval
delete char -6 to -1 of tInterval
put tInterval into tMyName
if tMyName = "Start" then
put "End" into tOtherName
else
put "Start" into tOtherName
end if
put left of grc "sliderbase" into baseLeft
put right of grc "sliderbase" into baseRight
put item 2 of the loc of grc "startSlider" into tVslider
put (width of me div 2) into W
put w * 2 into tBtnSpaceFromCenter
put baseLeft,left of grc "endslider" - W into tLimitsStart
put right of grc "startslider" + W,baseRight into tLimitsEnd
put width of grc "sliderbase"/48 into tInc
put true into allowDrag
end mouseDown
on mouseMove X,Y
put x + tHDiff into x
put y + tVDiff into y
if not allowDrag then exit mouseMove
if tMyName = "Start" then
lock screen
put min(max(X,item 1 of tLimitsStart),item 2 of tLimitsStart) into
tNewX
if tNewX < X then
put min(x,(baseRight - tBtnSpaceFromCenter)) into taLocX
set loc of grc "startSlider" to taLocX,tVslider
set loc of grc "endslider" to min(taLocX+tBtnSpaceFromCenter,the
right of grc sliderbase),tVslider
put left of grc sliderbase,left of grc "endslider" - W into
tLimitsStart
else
set loc of grc "startSlider" to tNewX,tVslider
end if
end if
if tMyName = "End" then
put min(max(X,item 1 of tLimitsEnd),item 2 of tLimitsEnd) into tNewX
put x && tNewX
if X < tNewX then
put min(max(x,baseLeft+tBtnSpaceFromCenter),(baseRight)) into
taLocX
set loc of grc "endslider" to taLocX,tVslider
set loc of grc "startSlider" to
max(baseLeft,taLocX-tBtnSpaceFromCenter),tVslider
put right of grc "startslider" + W,baseRight into tLimitsEnd
else
set loc of grc "endslider" to min(X,baseRight),tVslider
end if
end if
put "AM" into ampm
put (round((item 1 of the loc of grc (tMyName & "slider") -
baseLeft)/tInc)*15) into tMin
put trunc(tMin/60) + 6 into tHour
if tHour >= 12 then put "PM" into ampm
if tHour >= 13 then add -12 to tHour
put toUpper(tMyName) & ":" && tHour & ":" & format("%02s",tMin mod 60) &&
ampm into fld (tMyName & "output")
put "AM" into ampm
put (round((item 1 of the loc of grc (tOtherName & "slider") -
baseLeft)/tInc)*15) into tMin
put trunc(tMin/60) + 6 into tHour
if tHour >= 12 then put "PM" into ampm
if tHour >= 13 then add -12 to tHour
put toUpper(tOtherName) & ":" && tHour & ":" & format("%02s",tMin mod 60)
&& ampm into fld (tOtherName & "output")
unlock screen
end mouseMove
on mouseUp
put false into allowDrag
end mouseUp
on mouseRelease
put false into allowDrag
end mouseRelease
--------------------------------------------
again thank you very much.
regards
Bernd
--
View this message in context: http://n4.nabble.com/How-to-enter-a-time-of-day-tp1562955p1566711.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list