-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
Adding events to native Windows libraries #960
Comments
Use package test;
import com.formdev.flatlaf.FlatDarkLaf;
import javax.swing.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
public class WindowsListenerTest {
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
FlatDarkLaf.setup();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.addComponentListener( new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
System.out.println( e );
}
@Override
public void componentMoved(ComponentEvent e) {
System.out.println( e );
}
} );
frame.setVisible(true);
});
}
}
You could use a
How does this work? |
Hey Thanks for your answer. I made a few mistakes in my issue, in fact the event I'm looking for is when the user releases the mouse after a resize or move. Yes, I'm trying to achieve a swing implementation, while keeping the native window titles and borders. On MacOS when you resize a window to stick it onto another, when the two frame touch, the OS no longer interpret mouse movements events through several pixels. I can't same behaviour like macos, beucause I don't know how to block the movement or resizing of a frame, with native Windows borders. I'd already tried your solution using a timer that modify the frame if no more events were received. I also tried moving the user's mouse, but again, it is not user friendly. That's why, I try to display visual indicator to prevent the stick event, and when use releases it the two frame stick together. magnet_exemple.mp4 |
Hi,
Currently with native windows it doesn't seem possible to know when a user resizes or moves a window.
Indeed, no event seems to be sent to the JVM allowing to know if the user has released the mouse.
Since my application runs on Windows, one solution I found was to modify FlatWndPoc.cpp, to add a
sendMessageToClientArea( hwnd, WM_MOUSEMOVE, lParam
), when WM_EXITSIZEMOVE occurs.Can it be possible to incorporate this type of modification into the library, or do you have any tips can be help me with my problem?
please
Context:
My goal is to magnet windows on my application.
On Mac and some Linux distributions, this is already handled natively.
On Windows, there doesn't seem to be a native solution, and I've found that native window management doesn't allow me to prevent the system from moving or resizing a window.
To get around this problem, I want to magnet windows after the user has finished resizing or moving them.
The text was updated successfully, but these errors were encountered: