Create a fixed position window in Mac Application development - swift

I'm new in Mac Application development. I want to create a small tool which having a small window fixed position at the right bottom of the screen like this picture:
Is it possible to do that?

It's possible - but I wouldn't recommend it, as it could be a bad user experience.
The solution is simple, though: set the .isMovable property of the window to false.
For example, for a window IBOutlet, setting:
window.isMovable = false
in applicationDidFinishLaunching works well.
You can also, for example, use window.setFrameOrigin(_ point: NSPoint) to first set it at a fixed position.

Related

Disable bringing app window to front. After closing another window

I have OSX App that contains 2 NSWindowControllers. My problem is described by few steps:
Launch the app with 2 windows
Select the window of another app
Put 1 of the windows in front of anther app window and the second will stay in the bottom.
Close the window in the top.
The second window will be brought to the top immediately.(I need to fix it and keep my second window in the bottom.)
Also I hope to cancel this behavior. Not just make an opposite action like NSApp.hide()/NSApp.deactivate etc.
I know that it is a default behavor(e.g. Finder do the same), but I have to disable it. Also the case I've just described is a bit strange, but in my app it is really needed =(
I've tried to override becomeKey, becomeMain for main window, but it hasn't help.
override func becomeKey() {
}
override func becomeMain() {
}
PS
I'll be thankful for any ideas.

How can I make an OS X application unfocusable while still receiving click events?

I'm developing an on screen keyboard application for OS X, similar to the one that's built in to the operating system (Keyboard Viewer). I seem to have hit a wall as I'm not sure how I can accept click events from buttons and not steal focus from the currently activated application. I know this is possible since there are apps that already do this, e.g. AssistiveWere's KeyStrokes.
So my question is this: How can I make my window receive mouse events and handle them without getting activated?
P.S. I'm not very experienced in OS X development and this is my first Swift project, so excuses if this is a trivial problem.
You need to make your window an instance of NSPanel (or a subclass), include NSNonactivatingPanelMask in its styleMask, and set becomesKeyOnlyIfNeeded to true. (The style mask can be controlled in IB.) You probably also want it to be floating so it's always above normal windows, so set floatingPanel to true, too.

Swift - disable accessibility voiceover?

I was curious if there was a way to disable the voiceover accessibility (or any other type of accessibility feature for that matter - like hear aids, captioning, etc.) in swift?
Essentially, I'm trying to build an application that has a very high likelihood of being used by people with visual impairments and I've tailored my entire application for such people.
But given that this target group may have the voiceover accessibility feature on, can I disable that only within my application?
I see that on xcode 7, underneath the identity inspector, there is a section for accessibility (picture below) and I tried unchecking that box but it seems like voiceover and the highlighting focus feature are still in effect. Let me know if you have any suggestions or comments, thanks.
You can set
element.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction
on any elements that you want to provide custom audio/interactions for.
This can also be accomplished in storyboard (See photo).
I came across this thread because I was trying to do this for on a game scene tucked inside of a view container. To get it to work, I was able to set
.accessibilityTraits = UIAccessibilityTraitAllowsDirectInteraction
on each SKNode that had custom accessibility created for it, and then was able to select the proper options (again see screenshot) on the SKView -> View in Storyboard to allow the game screen to work.

Property additionalActions of NSUserNotification seems not working?

To understand NSUserNotification better, I wrote a little test app playing with this class.
So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.
My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.
Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?
Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?
Update
As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:
notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.
It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.
Besides setting additionalActions will cause several other problems. I will save this for another question.
Refer to another question.
show NSUserNotification additionalActions on click
P.S. I am using El Capitan APIs

SC.say location issue

I am currently facing an issue with fixing the location of SC.say pop up on the screen. The default behaviour of this pop up is okay, as in , it comes at the center of the screen. But then, once you drag this pop up to a corner of the screen, then , the next time when this pop up comes , it comes at that same corner where you had dragged it to. The default behaviour of this pop up (as far as the location is concerned) changes when the user starts dragging it. Is there a way to switch back to the default behaviour irrespective of where the user drags this pop up to?? I checked the javadoc of this SC class, but couldn't get any function that would let us specify the location where this pop up should come.
SmartGWT version : 3.0
GWT version : 2.4
Browser : Firefox,IE,Chrome,Safari
If you didn't find an easy solution to this, I think the easiest way is doing a "SC.say" by yourself.
it's very easy to replicate the built-in dialogs and then add your own functionality.
Something could help you
Canvas popUp = Canvas.getById("isc_globalWarn_body");
popUp.setTop(where it was);
popUp.setLeft(.......);
popUp.setWidth(...);
etc.....
I find the id with the console and the Canvas static method on a post somewhere on the net I don't remember where.