Re: ToggleFullScreenAction fails on MacOS

2018-06-16 Thread Patrik Karlström
Thank you, it works perfectly!

/Patrik

Den tors 7 juni 2018 kl 07:42 skrev Emilian Bold :

> What I see in ./applemenu/src/org/netbeans/modules/applemenu/layer.xml
> is that the generic action is hidden on macOS:
>
>  
>
> 
>  name="org-netbeans-core-windows-actions-ToggleFullScreenAction.instance_hidden"/>
> 
> 
>
>
> That's why you are getting a null.
>
> So, there is no API to call that action on macOS as far as I can tell.
>
> This workaround does the trick (inspired by
> https://gist.github.com/dohpaz42/4200907 ):
>
>
> @SuppressWarnings({"unchecked", "rawtypes"})
> public static void requestToggleFullScreen(Window window)
> {
> try {
> Class appClass = Class.forName("com.apple.eawt.Application");
> Class params[] = new Class[]{};
>
> Method getApplication = appClass.getMethod("getApplication",
> params);
> Object application = getApplication.invoke(appClass);
> Method requestToggleFulLScreen =
> application.getClass().getMethod("requestToggleFullScreen", Window.class);
>
> requestToggleFulLScreen.invoke(application, window);
> } catch (Exception e) {
> System.out.println("An exception occurred while trying to
> toggle full screen mode");
> }
> }
>
> requestToggleFullScreen(Frame.getWindows()[0]);
>
> --emi
>
> ‐‐‐ Original Message ‐‐‐
>
> On 6 June 2018 5:44 PM, Patrik Karlström  wrote:
>
> > Den ons 6 juni 2018 kl 14:36 skrev Emilian Bold <
> emilian.b...@protonmail.ch>:
> >
> > > The actual NPE might help. Maybe you have to create a dummy even and
> not send null to actionPerformed?
> > >
> > > If it's reproducible you should report it to the bugtracker
> https://issues.apache.org/jira/projects/NETBEANS/summary
> > >
> > > --emi
> > >
> > > ‐‐‐ Original Message ‐‐‐
> > >
> > > On 6 June 2018 2:36 PM, Patrik Karlström  wrote:
> > >
> > > > Hi,
> > >
> > > >
> > >
> > > > Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
> > >
> > > >
> > >
> > > > I *think* that I have successfully run the code above on a mac a
> couple of years back, but that might have been before they changed their
> maximize/full screen handling.
> > >
> > > >
> > >
> > > > Today I noticed that it failed with an NPE on the mac.
> >
> > Just noticed that it is the action itself that is null.
> >
> > Action a=Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction");
> >
> > results in a==null.
> >
> > All this is done on JDK8 171 and NetBeans 8.2, and on what I guess is an
> up to date Mac.
> >
> > How does it work on other Macs?
>


Re: ToggleFullScreenAction fails on MacOS

2018-06-07 Thread Patrik Karlström
Thanks for the hint but I'm trying to do this from a button in the toolbar
of a nb platform application.

Den tors 7 juni 2018 kl 00:05 skrev Brett Ryan :

> I haven’t experienced this behaviour, however; as a workaround, if you are
> ok with maximising NetBeans without going full screen, hold down the option
> key when clicking the green button.
>
> On 7 Jun 2018, at 00:44, Patrik Karlström  wrote:
>
> Den ons 6 juni 2018 kl 14:36 skrev Emilian Bold <
> emilian.b...@protonmail.ch>:
>
>> The actual NPE might help. Maybe you have to create a dummy even and not
>> send null to actionPerformed?
>>
>> If it's reproducible you should report it to the bugtracker
>> https://issues.apache.org/jira/projects/NETBEANS/summary
>>
>> --emi
>>
>> ‐‐‐ Original Message ‐‐‐
>>
>> On 6 June 2018 2:36 PM, Patrik Karlström  wrote:
>>
>> > Hi,
>> >
>> > Actions.forID("Window",
>> "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
>> >
>> > I *think* that I have successfully run the code above on a mac a couple
>> of years back, but that might have been before they changed their
>> maximize/full screen handling.
>> >
>> > Today I noticed that it failed with an NPE on the mac.
>>
>>
> Just noticed that it is the action itself that is null.
> Action a=Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction");
> results in a==null.
>
> All this is done on JDK8 171 and NetBeans 8.2, and on what I guess is an
> up to date Mac.
> How does it work on other Macs?
>
>


Re: ToggleFullScreenAction fails on MacOS

2018-06-06 Thread Emilian Bold
What I see in ./applemenu/src/org/netbeans/modules/applemenu/layer.xml is that 
the generic action is hidden on macOS:

 
   






That's why you are getting a null.

So, there is no API to call that action on macOS as far as I can tell.

This workaround does the trick (inspired by 
https://gist.github.com/dohpaz42/4200907 ):


@SuppressWarnings({"unchecked", "rawtypes"})
public static void requestToggleFullScreen(Window window)
{
try {
Class appClass = Class.forName("com.apple.eawt.Application");
Class params[] = new Class[]{};

Method getApplication = appClass.getMethod("getApplication", 
params);
Object application = getApplication.invoke(appClass);
Method requestToggleFulLScreen = 
application.getClass().getMethod("requestToggleFullScreen", Window.class);

requestToggleFulLScreen.invoke(application, window);
} catch (Exception e) {
System.out.println("An exception occurred while trying to toggle 
full screen mode");
}
}

requestToggleFullScreen(Frame.getWindows()[0]);

--emi

‐‐‐ Original Message ‐‐‐

On 6 June 2018 5:44 PM, Patrik Karlström  wrote:

> Den ons 6 juni 2018 kl 14:36 skrev Emilian Bold :
> 
> > The actual NPE might help. Maybe you have to create a dummy even and not 
> > send null to actionPerformed?
> > 
> > If it's reproducible you should report it to the bugtracker 
> > https://issues.apache.org/jira/projects/NETBEANS/summary
> > 
> > --emi
> > 
> > ‐‐‐ Original Message ‐‐‐
> > 
> > On 6 June 2018 2:36 PM, Patrik Karlström  wrote:
> > 
> > > Hi,
> > 
> > >
> > 
> > > Actions.forID("Window", 
> > > "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
> > 
> > >
> > 
> > > I *think* that I have successfully run the code above on a mac a couple 
> > > of years back, but that might have been before they changed their 
> > > maximize/full screen handling.
> > 
> > >
> > 
> > > Today I noticed that it failed with an NPE on the mac.
> 
> Just noticed that it is the action itself that is null.
> 
> Action a=Actions.forID("Window", 
> "org.netbeans.core.windows.actions.ToggleFullScreenAction");
> 
> results in a==null.
> 
> All this is done on JDK8 171 and NetBeans 8.2, and on what I guess is an up 
> to date Mac.
> 
> How does it work on other Macs?

-
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists



Re: ToggleFullScreenAction fails on MacOS

2018-06-06 Thread Patrik Karlström
Den ons 6 juni 2018 kl 14:36 skrev Emilian Bold :

> The actual NPE might help. Maybe you have to create a dummy even and not
> send null to actionPerformed?
>
> If it's reproducible you should report it to the bugtracker
> https://issues.apache.org/jira/projects/NETBEANS/summary
>
> --emi
>
> ‐‐‐ Original Message ‐‐‐
>
> On 6 June 2018 2:36 PM, Patrik Karlström  wrote:
>
> > Hi,
> >
> > Actions.forID("Window",
> "org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);
> >
> > I *think* that I have successfully run the code above on a mac a couple
> of years back, but that might have been before they changed their
> maximize/full screen handling.
> >
> > Today I noticed that it failed with an NPE on the mac.
>
>
Just noticed that it is the action itself that is null.
Action a=Actions.forID("Window",
"org.netbeans.core.windows.actions.ToggleFullScreenAction");
results in a==null.

All this is done on JDK8 171 and NetBeans 8.2, and on what I guess is an up
to date Mac.
How does it work on other Macs?


ToggleFullScreenAction fails on MacOS

2018-06-06 Thread Patrik Karlström
Hi,

Actions.forID("Window",
"org.netbeans.core.windows.actions.ToggleFullScreenAction").actionPerformed(null);

I *think* that I have successfully run the code above on a mac a couple of
years back, but that might have been before they changed their
maximize/full screen handling.

Today I noticed that it failed with an NPE on the mac.
It works fine on Windows and Linux.

Any ideas?

/Patrik