Friday, 3 August 2012

Mouse scrolling wheel 2

The last post created some questions, so I write an example for scrolling two different area only when the mouse is on one of them. This way only the area with the mouse on top will scroll:

Here the code:

Rebol []
insert-event-func   [
  switch event/type [
    scroll-line [
        if b_over [b/para/scroll: b/para/scroll + event/offset   show b]
        if c_over [c/para/scroll: c/para/scroll + event/offset show c]        
        ]
    scroll-page [
        if b_over [b/para/scroll: b/para/scroll + event/offset show b]    
        if c_over [c/para/scroll: c/para/scroll + event/offset show c]    
        ]
    ]  
  event
  ]  
b_over: c_over: false  
view layout [
  text "You can scroll this text with mouse wheel and mouse wheel + CTRL."
  text "Your mouse must be on the relative area to scroll."
  b: area system/license feel [
      over: func [face act pos] [b_over: act ]
      ]            
  c: area sky system/license feel [
      over: func [face act pos] [c_over: act ]
      ]
  ]

No comments:

Post a Comment