Skip to content
Permalink
Browse files

adding a label for user feedback from dragging

  • Loading branch information
ejdraper committed May 19, 2015
1 parent a0944a6 commit f48172149ab389831d2242c53f6c9b70f628f972
Showing with 20 additions and 0 deletions.
  1. +20 −0 app/app_delegate.rb
@@ -6,6 +6,16 @@ def applicationDidFinishLaunching(notification)
@drag_and_drop = DragAndDropView.alloc.initWithFrame(CGRectZero)
self.set_drag_and_drop_frame
@mainWindow.contentView.addSubview(@drag_and_drop)

@label = NSTextField.alloc.initWithFrame(CGRectZero)
@label.bezeled = false
@label.drawsBackground = false
@label.editable = false
@label.selectable = false
@label.alignment = NSCenterTextAlignment
@label.stringValue = "Drag a file above"
self.set_label_frame
@mainWindow.contentView.addSubview @label
end

def set_drag_and_drop_frame
@@ -17,6 +27,15 @@ def set_drag_and_drop_frame
]
end

def set_label_frame
window_size = @mainWindow.frame.size
label_size = [200, 50]
@label.frame = [
[(window_size.width / 2.0) - (label_size[0] / 2.0), @drag_and_drop.frame.origin.y - label_size[1]],
label_size
]
end

def buildWindow
@mainWindow = NSWindow.alloc.initWithContentRect([[240, 180], [480, 360]],
styleMask: NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask,
@@ -29,5 +48,6 @@ def buildWindow

def windowDidResize(sender)
self.set_drag_and_drop_frame
self.set_label_frame
end
end

0 comments on commit f481721

Please sign in to comment.
You can’t perform that action at this time.