Create java apps with MacBook Pro touchpad support?

as the fragment is described, I would like to be able to add some cool toolbar buttons to the java application for MacBook Pro 2016 users. I have not yet seen if there is a way to implement it in java.

Has anyone found out about this?

+5
source share
2 answers

There is a new Java library for interacting with the NSTouchBar API called JTouchBar .

For example, using SWT

Shell shell = ... JTouchBar jTouchBar = new JTouchBar(); jTouchBar.setCustomizationIdentifier("MySWTJavaTouchBar"); // flexible space jTouchBar.addItem(new TouchBarItem(TouchBarItem.NSTouchBarItemIdentifierFlexibleSpace)); // button TouchBarButton touchBarButtonImg = new TouchBarButton(); touchBarButtonImg.setTitle("Button 1"); touchBarButtonImg.setAction(new TouchBarViewAction() { @Override public void onCall( TouchBarView view ) { System.out.println("Clicked Button_1."); } }); Image image = new Image(); img.setName(ImageName.NSImageNameTouchBarColorPickerFill); touchBarButtonImg.setImage(image); jTouchBar.addItem(new TouchBarItem("Button_1", touchBarButtonImg, true)); // label TouchBarTextField touchBarTextField = new TouchBarTextField(); touchBarTextField.setStringValue("TextField 1"); jTouchBar.addItem(new TouchBarItem("TextField_1", touchBarTextField, true)); // enable touchbar jTouchBar.enableForShell(shell); 

You can find the library on Github: https://github.com/Thizzer/JTouchBar

+5
source

In appearance, the apple does not provide support for adding items to the touchpad, no matter it does in java.

When viewing some documents for the touchpad, you will also need an instance of the NSTouchBarItem class. Java does not have this and does not provide a way to get this. I doubt that using native methods will work, and also see how the instance is application specific and passed to the application through apple.

Access to the panel is possible, but only initially.

+3
source

Source: https://habr.com/ru/post/1261458/


All Articles