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

Mouse-related Issue in egui\examples\custom_window_frame #3809

Closed
rustbasic opened this issue Jan 12, 2024 · 4 comments · Fixed by #3833
Closed

Mouse-related Issue in egui\examples\custom_window_frame #3809

rustbasic opened this issue Jan 12, 2024 · 4 comments · Fixed by #3833
Labels
bug Something is broken

Comments

@rustbasic
Copy link
Contributor

rustbasic commented Jan 12, 2024

Title: Mouse-related Issue in egui\examples\custom_window_frame

@emilk
Dear emilk,

In the egui\examples\custom_window_frame,
there is an issue with moving the window using the mouse.
Therefore, I made the following modification to line 109 in egui\examples\custom_window_frame\src\main.rs:

    if title_bar_response.double_clicked() {                                          
        let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));     
        ui.ctx()                                                                      
            .send_viewport_cmd(ViewportCommand::Maximized(!is_maximized));            
                                                                                      
    }                                                                                 
//    } else if title_bar_response.is_pointer_button_down_on() {                                   
    if title_bar_response.is_pointer_button_down_on() {                               
        ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag);                       
    }                                                                                 

With this modification, the window moves correctly initially.
Even when changing to "maximized" by selecting the icon without double-clicking and returning to the original size,
it moves without any issues.

However, if the screen is changed to "maximized" by double-clicking and then returned to the original size,
attempting to move it again does not work at all.

Thank you,
emilk.

egui version: egui v0.25.0
OS: Windows 10

prev issue:
#3669

@rustbasic rustbasic added the bug Something is broken label Jan 12, 2024
@rustbasic
Copy link
Contributor Author

rustbasic commented Jan 12, 2024

@emilk

When maximized by pressing the button on the menu and then returning to the original size,
the title can be dragged by clicking it.
However, when minimized by pressing the button on the menu and then returning to the original size,
the title cannot be dragged by clicking it.

It seems to be related to checking and saving the minimized or maximized state.

@emilk
Copy link
Owner

emilk commented Jan 12, 2024

I don't have a Windows computer, so I would appreciate if you could investigate and make a PR!

@rustbasic
Copy link
Contributor Author

rustbasic commented Jan 13, 2024

@emilk
Dear emilk.

If the double_clicked() part of the 102nd line is all commented out and executed,
the title can be clicked and dragged normally.
However, after double-clicking ( or clicking ) the title for no reason, dragging does not work.
The title_bar_response.is_pointer_button_down_on() function returns true normally.
This suggests that there is a problem
with the ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag) function.

/*
    // Interact with the title bar (drag to move window):
    if title_bar_response.double_clicked() {
        let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));
        ui.ctx()
            .send_viewport_cmd(ViewportCommand::Maximized(!is_maximized));
    }
//    } else if title_bar_response.is_pointer_button_down_on() {
*/
    if title_bar_response.is_pointer_button_down_on() {
        ui.ctx().send_viewport_cmd(ViewportCommand::StartDrag);
    }

This issue is separate from the bug where, after using ui.ctx().send_viewport_cmd() to minimize, it still recognizes it as minimized, preventing dragging.

Thanks, emilk.

egui version: egui v0.25.0 - this issue bug.
egui v0.24.0 or Other Version - normally, no issue.

@axxop
Copy link
Contributor

axxop commented Jan 15, 2024

same #3791

rustbasic added a commit to rustbasic/egui that referenced this issue Jan 17, 2024
rustbasic added a commit to rustbasic/egui that referenced this issue Jan 17, 2024
emilk added a commit that referenced this issue Jan 17, 2024
…e the button is released (#3833)

* Closes #3809
* Closes #3669
* Closes #3791

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
3 participants