UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

SOLVED: resizing view width DragGesture MacOS

Forums > SwiftUI

Anyone has any tips on properly implementing resizing. (Think colmn width in Numbers). DragGesture works fine but the problem is correctly handling cursor shape. Imagine table header with # being target area for DragGesture:

| c1 #| c2 #| c3 #|

so you can use on hover to change the cursor to resizeLeftRight ( <-||-> )when hovering over # (area for dragging) and keeping it as resizeLeftRight ( <-||-> ) while user is dragging (even if user moves vertically leaving the # area) problem is if users stops dragging but keeps the mouse button down I want to keep the cursor as <-||-> but change it back to regular cursor if user releases mouse button. .onEnded for DragGesture will get called as soon as user stops dragging regardless if mouse button is still down or not. I need to make a determination if I need to change the cursor shape inside .onEnded based ob mouse button state but not sure how to properly do it? Any tips would be appreciated

2      

OK so trick is when using DragGesture init with (minimumDistance: 0) than .onEnd will not fire until mouse button is released

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.