FLTK logo

[fltk.general] Re: While Dragging, trigger the Move/Enter event for widget under the mouse

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: While Dragging, trigger the Move/Enter event for widget under the mouse Mo_Al_ Jun 29, 2021  
  Just to update the list that this was answered here:
https://github.com/fltk-rs/fltk-rs/discussions/751

On Tuesday, June 29, 2021 at 1:40:22 AM UTC+3 caroli...@gmail.com wrote:

Is it possible to trigger a Move/Enter/Leave action on a widget whilst dragging a different widget? I'm working on a drag and drop system and I need some way to trigger callbacks on whatever is under the mouse while I'm dragging.

However it seems that while dragging, you can't trigger events on other widgets. If you start dragging the drag_button, then move over the move_over_button, then no events are triggered for the move_over_button. 

Code is in Rust with fltk-rs.

```

use fltk::{app::*, button::*, frame::*, enums::*, window::*, group::*, prelude::*, };


fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = App::default();
    let mut win = Window::new(200, 200, 500, 300, "Drag and Move ");
    let mut container= Pack::new(50,50,300,200,None);
    container.set_type(PackType::Horizontal);

    //while dragging this button
    let mut drag_button= Button::new(0,0,200,60,"Drag Me!");
    drag_button.handle(move|widg, ev|{
      match ev{
        Event::Drag=>{
            dbg!("im dragging from Drag Button");
            true
        }
        _=>false              
      }
    });
    //we want to trigger these events in this button
    let mut move_over_button= Button::new(200,0,200,60,"Then Move Over me");
    move_over_button.handle(move|widg, ev|{
      match ev{
        Event::Move=>{
            dbg!("I got moved over");
            true
        }
        Event::Enter=>{
            dbg!("I got entered over");
            true
        }
        _=>false              
      }
    });
    container.end();
    win.end();
    win.show();

    while app.wait() {}
    Ok(())
}

```

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/f4ef7bc9-9d6c-4ef4-a023-b1a5723e6cf4n%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.