Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WM_MOUSEMOVE for controls? #12

Closed
GirkovArpa opened this issue Aug 12, 2021 · 4 comments
Closed

WM_MOUSEMOVE for controls? #12

GirkovArpa opened this issue Aug 12, 2021 · 4 comments
Assignees
Labels
gui Something within the gui module question Further information is requested

Comments

@GirkovArpa
Copy link

I would like to handle MOUSEMOVE for a label, but it doesn't have such an event. I don't think labels support custom messages like here, right?

I can't use self.wnd.on().wm_mouse_move({ because it stops firing when the cursor moves over a control.

@GirkovArpa
Copy link
Author

I can use GetCursorPos in conjunction with ScreenToClient inside a loop, actually.

@rodrigocfd
Copy link
Owner

If you want to handle non-ordinary messages in a native control, you must subclass it, which is automatically done through on_subclass method.

Take care though. Subclassing is very dangerous, because you're messing with the internal message handling of the native control.

@GirkovArpa
Copy link
Author

Is this correct? It works, but I don't know if it's best to put it inside fn events(&self) { /* ... */ }.

fn events(&self) {
  let label_events = self.lbl.on_subclass();
  label_events.wm_mouse_move({
    move |params| {
      println!("{},{}", params.coords.x, params.coords.y);
    }
  });

@rodrigocfd
Copy link
Owner

I can't test it right now, but it appears to be correct.

@rodrigocfd rodrigocfd added the question Further information is requested label May 12, 2022
@rodrigocfd rodrigocfd self-assigned this Jan 25, 2023
@rodrigocfd rodrigocfd added the gui Something within the gui module label Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui Something within the gui module question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants