minor fix for rollovers

cvs
Slava Pestov 2005-02-20 03:55:45 +00:00
parent 3b98c55ecf
commit ae27f48d12
4 changed files with 11 additions and 4 deletions

View File

@ -26,7 +26,6 @@
- ffi unicode strings: null char security hole - ffi unicode strings: null char security hole
- utf16 string boxing - utf16 string boxing
- sdl console crash - sdl console crash
- UI: don't roll over if mouse button is down
- more accurate types for various words - more accurate types for various words
- optimize out >array, >tuple, >hashtable etc - optimize out >array, >tuple, >hashtable etc
- write read: write should flush - write read: write should flush

View File

@ -11,12 +11,17 @@ USING: generic kernel lists math namespaces sdl ;
: mouse-over? ( gadget -- ? ) my-hand hand-gadget child? ; : mouse-over? ( gadget -- ? ) my-hand hand-gadget child? ;
: button-rollover? ( button -- ? )
mouse-over? 1 button-down? not and ;
: rollover-update ( button -- ) : rollover-update ( button -- )
dup mouse-over? blue black ? foreground set-paint-property ; dup button-rollover? blue black ? foreground set-paint-property ;
: button-pressed? ( button -- ? ) : button-pressed? ( button -- ? )
#! Return true if the mouse was clicked on the button, and
#! is currently over the button.
dup mouse-over? [ dup mouse-over? [
my-hand hand-buttons 1 swap contains? [ 1 button-down? [
my-hand hand-clicked child? my-hand hand-clicked child?
] [ ] [
drop f drop f

View File

@ -76,3 +76,6 @@ SYMBOL: button-down
[ [
2dup child? [ gain-focus ] hierarchy-gesture 2dup child? [ gain-focus ] hierarchy-gesture
] each-parent 2drop ; ] each-parent 2drop ;
: button-down? ( n -- ? )
my-hand hand-buttons contains? ;

View File

@ -47,7 +47,7 @@ DEFER: handle-event
#! Keep polling for events until there are no more events in #! Keep polling for events until there are no more events in
#! the queue; then block for the next event. #! the queue; then block for the next event.
dup SDL_PollEvent [ dup SDL_PollEvent [
dup handle-event eat-events [ handle-event ] in-thread eat-events
] [ ] [
world get world-step [ SDL_WaitEvent ] [ drop f ] ifte world get world-step [ SDL_WaitEvent ] [ drop f ] ifte
] ifte ; ] ifte ;