void windowWillClose(long /*int*/ id, long /*int*/ sel, long /*int*/ sender) { NSApplication.sharedApplication().stop(null); } }
public void run() { NSApplication.sharedApplication().terminate(null); } });
void windowWillClose(long /*int*/ id, long /*int*/ sel, long /*int*/ sender) { NSApplication.sharedApplication().stop(null); }
boolean tableView_writeRowsWithIndexes_toPasteboard(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2) { return sendMouseEvent(NSApplication.sharedApplication().currentEvent(), SWT.DragDetect, true); }
boolean outlineView_writeItems_toPasteboard(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2) { return sendMouseEvent(NSApplication.sharedApplication().currentEvent(), SWT.DragDetect, true); }
int getOperationFromKeyState() { // The NSDraggingInfo object already combined the modifier keys with the // drag source's allowed events. This might be better accomplished by diffing // the base drag source mask with the active drag state mask instead of snarfing // the current event. // See documentation on [NSDraggingInfo draggingSourceOperationMask] for the // correct Cocoa behavior. Control + Option or Command is NSDragOperationGeneric, // or DND.DROP_DEFAULT in the SWT. NSEvent currEvent = NSApplication.sharedApplication().currentEvent(); long /*int*/ modifiers = currEvent.modifierFlags(); boolean option = (modifiers & OS.NSAlternateKeyMask) == OS.NSAlternateKeyMask; boolean control = (modifiers & OS.NSControlKeyMask) == OS.NSControlKeyMask; if (control && option) return DND.DROP_DEFAULT; if (control) return DND.DROP_LINK; if (option) return DND.DROP_COPY; return DND.DROP_DEFAULT; }
void sendSelection () { NSEvent currEvent = NSApplication.sharedApplication().currentEvent(); if (currEvent.type() != OS.NSLeftMouseUp) sendSelectionEvent (SWT.Selection); }
void createWidget () { NSApplication app = NSApplication.sharedApplication (); NSImage image = app.applicationIconImage (); defaultImage = new NSImage (image.copy ()); }
void panelDidEnd_returnCode_contextInfo(long /*int*/ id, long /*int*/ sel, long /*int*/ alert, long /*int*/ returnCode, long /*int*/ contextInfo) { this.returnCode = (int)/*64*/returnCode; NSApplication application = NSApplication.sharedApplication(); application.endSheet(new NSAlert(alert).window(), returnCode); }
void updateOverlayText (String string) { NSApplication app = NSApplication.sharedApplication (); NSDockTile dock = app.dockTile (); if (string != null && string.length () > 0) { dock.setBadgeLabel (NSString.stringWith (string)); } else { dock.setBadgeLabel (null); } }
void sendSelectionEvent (int eventType, Event event, boolean send) { if (eventTable == null && !display.filters (eventType)) { return; } if (event == null) event = new Event (); NSEvent nsEvent = NSApplication.sharedApplication ().currentEvent (); if (nsEvent != null) setInputState (event, nsEvent, 0); sendEvent(eventType, event, send); }
void sendSelection () { NSEvent event = NSApplication.sharedApplication().currentEvent(); if (event != null && (style & SWT.CALENDAR) != 0) { if (event.clickCount() == 2) { sendSelectionEvent (SWT.DefaultSelection); } else if (event.type() == OS.NSLeftMouseUp) { sendSelectionEvent (SWT.Selection); } } else { // SWT.DATE or SWT.TIME sendSelectionEvent (SWT.Selection); } }
void cancelOperation(long /*int*/ id, long /*int*/ sel, long /*int*/ sender) { // Cmd-. and escape arrive here. Forward the current event as a key event. if (hasKeyboardFocus(id)) { NSEvent nsEvent = NSApplication.sharedApplication().currentEvent(); Shell s = this.getShell(); s.keyInputHappened = false; boolean [] consume = new boolean [1]; if (translateTraversal (nsEvent.keyCode (), nsEvent, consume)) return; if (isDisposed ()) return; if (!sendKeyEvent (nsEvent, SWT.KeyDown)) return; } }
boolean canBecomeKeyWindow (long /*int*/ id, long /*int*/ sel) { if (isPopup) return false; // Only answer if SWT created the window. if (window != null) { if ((style & SWT.NO_FOCUS) != 0) { NSEvent nsEvent = NSApplication.sharedApplication().currentEvent(); if (nsEvent != null && nsEvent.type() == OS.NSLeftMouseDown) { NSView contentView = window.contentView(); if (contentView != null) { NSView view = contentView.hitTest(nsEvent.locationInWindow()); if (view == contentView) return false; } } } long /*int*/ styleMask = window.styleMask(); if (styleMask == OS.NSBorderlessWindowMask || (styleMask & (OS.NSNonactivatingPanelMask | OS.NSDocModalWindowMask | OS.NSResizableWindowMask)) != 0) return true; } return super.canBecomeKeyWindow (id, sel); }
int createBaseWindow (nsIBaseWindow baseWindow) { browser.getDisplay ().setData (MOZILLA_RUNNING, Boolean.TRUE); /* * Feature of Mozilla on OSX. Mozilla replaces the OSX application menu whenever * a browser's base window is created. The workaround is to restore the previous * menu after creating the base window. */ NSApplication application = NSApplication.sharedApplication (); NSMenu mainMenu = application.mainMenu (); if (mainMenu != null) mainMenu.retain (); int rc = baseWindow.Create (); application.setMainMenu (mainMenu); if (mainMenu != null) mainMenu.release (); ((Mozilla)browser.webBrowser).Activate (); return rc; }
void sendSelection () { if ((style & SWT.CHECK) != 0) { setSelection (!getSelection ()); } else { if ((style & SWT.RADIO) != 0) { if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) { setSelection (!getSelection ()); } else { selectRadio (); } } } Event event = new Event (); sendSelectionEvent (SWT.Selection, event, nsItemAction != 0); // Widget may be disposed at this point if (isDisposed()) return; if (nsItemAction != 0) { if (event.doit) { NSApplication app = NSApplication.sharedApplication(); app.sendAction(nsItemAction, nsItemTarget, app); } } }
boolean canDragRowsWithIndexes_atPoint(long /*int*/ id, long /*int*/ sel, long /*int*/ rowIndexes, NSPoint mouseDownPoint) { if (!super.canDragRowsWithIndexes_atPoint(id, sel, rowIndexes, mouseDownPoint)) return false; // If the current row is not selected and the user is not attempting to modify the selection, select the row first. NSTableView widget = (NSTableView)view; long /*int*/ row = widget.rowAtPoint(mouseDownPoint); long /*int*/ modifiers = NSApplication.sharedApplication().currentEvent().modifierFlags(); boolean drag = (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect); if (drag) { if (!widget.isRowSelected(row) && (modifiers & (OS.NSCommandKeyMask | OS.NSShiftKeyMask | OS.NSAlternateKeyMask | OS.NSControlKeyMask)) == 0) { NSIndexSet set = (NSIndexSet)new NSIndexSet().alloc(); set = set.initWithIndex(row); widget.selectRowIndexes (set, false); set.release(); } } // The clicked row must be selected to initiate a drag. return (widget.isRowSelected(row) && drag) || !hasFocus(); }
Image getDragSourceImage(DragSourceEvent event) { if (dragSourceImage != null) dragSourceImage.dispose(); dragSourceImage = null; NSPoint point = new NSPoint(); long /*int*/ ptr = OS.malloc(NSPoint.sizeof); OS.memmove(ptr, point, NSPoint.sizeof); NSEvent nsEvent = NSApplication.sharedApplication().currentEvent(); NSTableView widget = (NSTableView)control.view; NSImage nsImage = widget.dragImageForRowsWithIndexes(widget.selectedRowIndexes(), widget.tableColumns(), nsEvent, ptr); OS.memmove(point, ptr, NSPoint.sizeof); OS.free(ptr); //TODO: Image representation wrong??? Image image = Image.cocoa_new(control.getDisplay(), SWT.BITMAP, nsImage); dragSourceImage = image; nsImage.retain(); event.offsetX = (int)point.x; event.offsetY = (int)point.y; return image; } }
boolean canDragRowsWithIndexes_atPoint(long /*int*/ id, long /*int*/ sel, long /*int*/ rowIndexes, NSPoint mouseDownPoint) { if (!super.canDragRowsWithIndexes_atPoint(id, sel, rowIndexes, mouseDownPoint)) return false; // If the current row is not selected and the user is not attempting to modify the selection, select the row first. NSTableView widget = (NSTableView)view; long /*int*/ row = widget.rowAtPoint(mouseDownPoint); long /*int*/ modifiers = NSApplication.sharedApplication().currentEvent().modifierFlags(); boolean drag = (state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect); if (drag) { if (!widget.isRowSelected(row) && (modifiers & (OS.NSCommandKeyMask | OS.NSShiftKeyMask | OS.NSAlternateKeyMask)) == 0) { NSIndexSet set = (NSIndexSet)new NSIndexSet().alloc(); set = set.initWithIndex(row); widget.selectRowIndexes (set, false); set.release(); } } // The clicked row must be selected to initiate a drag. return (widget.isRowSelected(row) && drag) || !hasFocus(); }
Image getDragSourceImage(DragSourceEvent event) { if (dragSourceImage != null) dragSourceImage.dispose(); dragSourceImage = null; NSPoint point = new NSPoint(); long /*int*/ ptr = OS.malloc(NSPoint.sizeof); OS.memmove(ptr, point, NSPoint.sizeof); NSEvent nsEvent = NSApplication.sharedApplication().currentEvent(); NSTableView widget = (NSTableView)control.view; NSImage nsImage = widget.dragImageForRowsWithIndexes(widget.selectedRowIndexes(), widget.tableColumns(), nsEvent, ptr); OS.memmove(point, ptr, NSPoint.sizeof); OS.free(ptr); //TODO: Image representation wrong??? Image image = Image.cocoa_new(control.getDisplay(), SWT.BITMAP, nsImage); dragSourceImage = image; nsImage.retain(); event.offsetX = (int)point.x; event.offsetY = (int)point.y; return image; } }