Quincey, Thanks. I’m using Xcode Version 6.4 (6E35b). Mac running 10.10.4. Programming in Swift 1.2.
Here is the mouse-down method with event loop. As you can see I am calling setFrameOrigin in the dragging case and setting frame directly in the resizing case. override func mouseDown (event: NSEvent) { var resizing = false var dragging = false let clickLocation = convertPoint(event.locationInWindow, fromView: nil) if resizePath.containsPoint(clickLocation) { resizing = true } else { dragging = true } // Remain in an event loop until left mouse up. let mask = NSEventMask.LeftMouseUpMask | NSEventMask.LeftMouseDraggedMask var lastDragLocation = superview!.convertPoint(event.locationInWindow, fromView: nil) while resizing || dragging { let event = window!.nextEventMatchingMask(Int(mask.rawValue)) if event == nil { continue } if event!.type == NSEventType.LeftMouseUp { resizing = false dragging = false } else if event!.type == NSEventType.LeftMouseDragged { let dragLocation = superview!.convertPoint(event!.locationInWindow, fromView: nil) if dragging { var origin = frame.origin origin.x += dragLocation.x - lastDragLocation.x origin.y += dragLocation.y - lastDragLocation.y setFrameOrigin(origin) needsDisplay = true } else if resizing { var origin = frame.origin var size = frame.size origin.y += dragLocation.y - lastDragLocation.y size.height -= dragLocation.y - lastDragLocation.y size.width += dragLocation.x - lastDragLocation.x frame = CGRect(origin: origin, size: size) needsLayout = true needsDisplay = true } lastDragLocation = dragLocation } } Tom Wetmore > On Jul 20, 2015, at 4:43 PM, Quincey Morris > <quinceymor...@rivergatesoftware.com> wrote: > > On Jul 20, 2015, at 13:30 , Thomas Wetmore <t...@verizon.net> wrote: >> >> When I instantiate one of these views and place it in an NSWindow, I can >> drag it around and I can resize it, as expected. Notably, however, I can >> resize it down to zero size (and even smaller!), even though the two >> constraints exist. I kind of expected the program to crash when the >> constraints were violated, but things keep on running. I can drag and resize >> the view at will with no repercussions. > > a. What version of Xcode are you using? > > b. What mechanism are you using (inside the mouse-down event loop) to change > the size? > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com