TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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 RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.