1. Re: auto-repeat button
Peter J. Modlich wrote:
> What I am missing is an auto-repeat button to
> scroll lists or a cursor through a graphical
> display.
I've rewritten get_mouse (in MOUSE.E) to perform as you've asked. Basically,
when a mouse event comes in, you test to see if it's a mousedown. If it is,
you set a flag and a retrigger time. Then, if the mouse is polled and
there's been no new event, it checks if the retrigger time has expired. If
it has, is retriggers the mouse event again, and sets the new retrigger
time. Releasing the mouse clears the flag, and stops the retrigger event.
I hope this helps!
-- David Cuny
-- replaces get_mouse in MOUSE.E
-- not tested extensively...
constant
FirstRetrigger = .5,
NextRetrigger = .2
integer mouseDown
atom mouseRetriggerTime
sequence mouseEvent
mouseDown = 0
mouseRetriggerTime = 0
global function get_mouse()
-- report mouse events,
-- returns -1 if no mouse event,
-- otherwise returns {event#, x-coord, y-coord, x/8, x/16}
object ret
if IsPtrOn=0 then
FatalExit("Mouse","Attempt to retrieve event while pointer is hidden.")
-- IsPtrOn=1
end if
ret = machine_func(M_GET_MOUSE, 0)
if sequence(ret) then
-- mouse down?
if and_bits( ret[1], LEFT_DOWN ) then
-- flag as mouseDown as true and set retrigger time
mouseDown = 1
mouseRetriggerTime = time() + FirstRetrigger
else
-- flag as false
mouseDown = 0
end if
-- adjust the coordinates
ret = ret & floor(ret[2]/8)+1 & floor(ret[3]/16)+1
-- save the event (for retriggering)
mouseEvent = ret
elsif mouseDown
and time() >= mouseRetriggerTime then
-- reset time
mouseRetriggerTime = time() + NextRetrigger
-- retrigger event
ret = mouseEvent
end if
return ret
end function