Supporting the Mac OS menubar in JavaFX
Jonathan Giles
jonathan.giles at oracle.com
Fri Dec 9 15:33:35 PST 2011
Rich,
Thanks - that's a good point about modularity. The approach you suggest
seems like a good alternative. It nicely avoids the need to specify a
MenuBar in two places (Application and in the developers scenegraph). I
have a few comments:
1) I'm assuming we would add a boolean property to MenuBar to allow for
developers to prevent the conversion to native if that wasn't their desire.
2) We would have to develop some semantics around what MenuBar becomes
the native menu bar. I would assume that it is the first MenuBar found
on the currently focused Stage that has the boolean mentioned in 1)
above set to allow for native conversion. In cases where a Stage is
brought up that does not have a MenuBar (or the menubar is not allowed
to convert to native), the previously converted menu bar will remain
showing.
Am I missing anything else?
-- Jonathan
-- Jonathan
On 10/12/2011 9:18 a.m., Richard Bair wrote:
> Hi Jonathan,
>
> There is one other problem, which is modularity. Having Application or Stage know about javafx.scene.control package would mean a new dependency. What about the idea that the MenuBarSkin either shows itself, or doesn't, based on OS? And hoists the contents into the Mac menu bar when needed?
>
> Richard
>
> On Dec 9, 2011, at 2:56 PM, Jonathan Giles wrote:
>
>> Hi all,
>>
>> One of the things we're planning to support in JavaFX 2.1 is the native Mac OS menubar. This email is intended primarily to discuss the API one expects to see to set a MenuBar in the native Mac OS menubar area. Your feedback is sought and will be very much appreciated.
>>
>> The current thinking is that Application feels like the right place to specify a global, application-wide javafx.scene.control.MenuBar on. It could be assumed that if a developer were to set this property, and the operating system upon which the end-user was running the JavaFX application was Mac OS, that the menubar will be displayed using the native Mac OS menubar. Of course, if a developer wants a cross-platform look and feel, they could just place the MenuBar in the stage as per usual and it would display as it currently does. This approach opens up a number of questions and issues:
>>
>> 1) What happens in the case of the end-user being on Windows? Is the Application.MenuBar ignored, or is it automagically added to the main Stage? (I would argue for totally ignoring it....but that leads to the next point).
>> 2) This approach means there needs to be operating specific code in the UI to test whether a non-native MenuBar should be added (in the case of Windows, for example). This starts to clutter the UI code, and without careful consideration by the developer may result in needing to duplicate their MenuBar code. Is there a better approach?
>>
>> Another place to specify a MenuBar would be on Stage, rather than (or in addition to), Application. Having a MenuBar property on Stage would allow for the MenuBar to change based on the currently focused Stage - but I'm not certain this is desirable or even the expected behaviour of Mac OS. Therefore, I'm thinking that this is not likely to happen unless we hear otherwise.
>>
>> Like I said, we're at a very early exploration point in this process. The controls team is very keen to hear feedback from the community, as well as from the owners of the Application API, and the Mac OS experts on this list.
>>
>> Thanks,
>> -- Jonathan
More information about the openjfx-dev
mailing list