public static NSApplication sharedApplication() { long /*int*/ result = OS.objc_msgSend(OS.class_NSApplication, OS.sel_sharedApplication); return result != 0 ? new NSApplication(result) : null; }
/** * If the receiver is visible, moves it to the top of the * drawing order for the display on which it was created * (so that all other shells on that display, which are not * the receiver's children will be drawn behind it) and forces * the window manager to make the shell active. * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * * @since 2.0 * @see Control#moveAbove * @see Control#setFocus * @see Control#setVisible * @see Display#getActiveShell * @see Decorations#setDefaultButton(Button) * @see Shell#open * @see Shell#setActive */ public void forceActive () { checkWidget (); if (!isVisible()) return; if (window == null) return; makeKeyAndOrderFront (); NSApplication application = NSApplication.sharedApplication (); application.activateIgnoringOtherApps (true); }
void createWidget () { NSApplication app = NSApplication.sharedApplication (); NSImage image = app.applicationIconImage (); defaultImage = new NSImage (image.copy ()); }
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); }
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); }
panel.setCanChooseFiles(false); panel.setCanChooseDirectories(true); NSApplication application = NSApplication.sharedApplication(); if (parent != null && (style & SWT.SHEET) != 0) { application.beginSheet(panel, parent.view.window (), null, 0, 0); long /*int*/ response = panel.runModalForDirectory(dir, null); if (parent != null && (style & SWT.SHEET) != 0) { application.endSheet(panel, 0);
NSApplication application = NSApplication.sharedApplication(); NSEvent currentEvent = application.currentEvent(); if (currentEvent != null) { switch ((int)/*64*/currentEvent.type()) { display.runSkin (); display.runDeferredLayouts (); NSEvent event = application.nextEventMatchingMask(0, NSDate.distantFuture(), OS.NSDefaultRunLoopMode, true); if (event == null) continue; int type = (int)/*64*/event.type(); dispatch = false; if (dispatch) application.sendEvent(event); if (clientCursor != null && resizeCursor == null) { display.lockCursor = false;
application.hideOtherApplications(application); } else if (sel == OS.sel_hide_) { application.hide(application); } else if (sel == OS.sel_unhideAllApplications_) { application.unhideAllApplications(application); } else if (sel == OS.sel_applicationDidBecomeActive_) { display.applicationDidBecomeActive(id, sel, arg0);
void updateImage () { boolean drawProgress = progress != 0 && progressState != SWT.DEFAULT; boolean drawIntermidiate = progressState == SWT.INDETERMINATE; NSApplication app = NSApplication.sharedApplication (); NSDockTile dock = app.dockTile (); boolean drawImage = overlayImage != null && dock.badgeLabel () == null; if (!drawImage && !drawProgress && !drawIntermidiate) { app.setApplicationIconImage (defaultImage); return; app.setApplicationIconImage (newImage); newImage.release ();
application.setDelegate(applicationDelegate); } else { application.finishLaunching(); Display.launched = true; NSMenu appleMenu = application.mainMenu().itemAtIndex(0).submenu(); NSMenuItem prefsItem = appleMenu.itemWithTag(SWT.ID_PREFERENCES); if (prefsItem != null) prefsItem.setTag(42);
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); } }
display.sendEvent(SWT.OpenDocument, event); new NSApplication(arg0).replyToOpenOrPrint(OS.NSApplicationDelegateReplySuccess); } else if (sel == OS.sel_applicationShouldHandleReopen_hasVisibleWindows_) { final Event event = new Event();
if (modalShell != null) { if (activate) { if (application.isActive()) { modalShell.window.orderFrontRegardless(); } else { application.activateIgnoringOtherApps(true);
int getLastEventTime () { NSEvent event = application.currentEvent(); if (event == null) return 0; double timestamp = event.timestamp() * 1000; while (timestamp > 0x7FFFFFFF) { timestamp -= 0x7FFFFFFF; } return (int)timestamp; }
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); }
if (window != null) { if ((style & (SWT.SHEET)) != 0) { NSApplication application = NSApplication.sharedApplication(); application.beginSheet(window, parentWindow (), null, 0, 0); if (OS.VERSION <= 0x1060 && window.respondsToSelector(OS.sel__setNeedsToUseHeartBeatWindow_)) { OS.objc_msgSend(window.id, OS.sel__setNeedsToUseHeartBeatWindow_, 0); if (window != null) { if ((style & (SWT.SHEET)) != 0) { NSApplication application = NSApplication.sharedApplication(); application.endSheet(window, 0);
void destroyWidget () { NSWindow window = this.window; if (window != null) window.retain(); Display display = this.display; NSView view = topView(); if (view != null) view.retain(); boolean sheet = (style & (SWT.SHEET)) != 0; releaseHandle (); if (window != null) { if (sheet) { NSApplication application = NSApplication.sharedApplication(); application.endSheet(window, 0); } window.close(); } else if (view != null) { view.removeFromSuperview(); } if (view != null) view.release(); // If another shell is not going to become active, clear the menu bar. // Don't modify the menu bar if we are an embedded Shell, though. if (window != null) { if (!display.isDisposed () && display.getShells ().length == 0) { display.setMenuBar (null); } window.release(); } }
if (hooks (SWT.Verify)) { String string = new NSString(replacementString).getString(); NSEvent currentEvent = display.application.currentEvent(); long /*int*/ type = currentEvent.type(); if (type != OS.NSKeyDown && type != OS.NSKeyUp) currentEvent = null;
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; }
NSApplication application = NSApplication.sharedApplication(); if (parent != null && (style & SWT.SHEET) != 0) { application.beginSheet(panel, parent.view.window (), null, 0, 0); long /*int*/ response = panel.runModalForDirectory(dir, file); if (parent != null && (style & SWT.SHEET) != 0) { application.endSheet(panel, 0);