Code Monkey home page Code Monkey logo

js-osx-app-examples's People

Contributors

tylergaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-osx-app-examples's Issues

These are all broken in Mojave

They all get

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSGetSizeAndAlignment(): unsupported type encoding spec 'G' at 'GPoint}"size"{CGSize}}' in '{CGPoint}"size"{CGSize}}''

Which seems to happen before many $.NSSomething calls, but certainly $.NSWindow.alloc...

Wondering:

a) can others replicate this?
b) ideas on the best way forward? Looks like Apple broke it, but was it intentional? How might we make them aware this was really useful.

NSMatrix selected item

your examples very awesome
how can i get NSMatrix selected item... Item.tag or item.index for example

Binding hotkeys?

Hi, thanks for your work on documenting how to build JavaScript for Automation apps. Your blogpost and examples are by far the best resources I've found so far.

I'm wondering if you know of any way to bind to keystroke events using JS for Automation? Ideally I'd like to respond to global keyboard events (ie. when the app is not focused), but I'm not sure if that's possible. Through searching around, it seems like an old Carbon API called RegisterEventHotKey is the way most OS X apps do this. It looks like you can import and use these APIs, my WIP attempt looks something like:

ObjC.import("Cocoa")
ObjC.import("Carbon")
var hotkeyHandler = function(evt) { $.NSLog('hello from handler') }
var evtType = { eventClass: $.kEventClassKeyboard, eventKind: $.kEventHotKeyPressed }
var keyCodeForV = 9

$.InstallEventHandler($.GetApplicationEventTarget(), hotkeyHandler, 1, evtType, {}, null)
s = $.RegisterEventHotKey(keyCodeForV, ($.controlKey | $.cmdKey), {id: 1, signature: 'asdf'}, $.GetApplicationEventTarget(), 0, {});

This doesn't work, but running each of the Carbon functions/variables through console.log shows that they are available and ready to use. The arguments that are empty object literals are the ones I'm unclear about.

The following links look useful for figuring this out, and looking at the Carbon header file at /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h has also been helpful:
http://stackoverflow.com/questions/8201338/how-to-implement-shortcut-key-input-in-mac-cocoa-app
http://dbachrach.com/blog/2005/11/program-global-hotkeys-in-cocoa-easily/
http://snippets.aktagon.com/snippets/361-registering-global-hot-keys-with-cocoa-and-objective-c

Not sure if an issue is the best way to ask this, but thought it might be useful to others as well if it was documented here. Any pointers or tips would be appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.