How to determine resize direction (left/right) during window resizing in Compose Desktop?

24 Views Asked by At

In Compose Desktop, I'm using Modifier.onGloballyPositioned to get notified when the window size changes. I need to know if the user is resizing from the left or right side of the app to handle specific behaviors. However, the modifier doesn't provide direct information about the cursor position during resizing.

What I've tried:

  • I've considered using Modifier.onMouseDown and Modifier.onMouseDrag to track the initial mouse position and compare it with subsequent positions during resizing, but this might not be reliable for all mouse interactions.
  • I've explored using window events through LocalContext.current.window and adding a listener for resize events, but I'm unsure how to analyze the ComponentEvent arguments to accurately determine the resizing direction.

What I'm asking:

  • Are there any recommended ways to achieve this functionality in Compose Desktop?

  • What are the pros and cons of using mouse events vs. window events for this purpose?

  • Are there any additional approaches I haven't considered?

  • How can I ensure my solution is performant and handles potential edge cases or conflicts?

  • List item

0

There are 0 best solutions below