Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Mac Menubar  (Read 10040 times)

0 Members and 1 Guest are viewing this topic.

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Mac Menubar
« on: May 15, 2012, 03:35:54 am »
Anyways to make this actually functional or add entries to it?


Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #1 on: May 15, 2012, 05:42:22 pm »
This is planned for 2.x. See https://github.com/SFML/SFML/issues/11
SFML / OS X developer

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Mac Menubar
« Reply #2 on: May 15, 2012, 08:58:02 pm »
Hmm, not what I was hoping to hear. I guess I might need to hack in my own simple menu bar somewhere, as I have a feeling Apple will likely reject this non-functional one.

Ceylo

  • Hero Member
  • *****
  • Posts: 2325
    • View Profile
    • http://sfemovie.yalir.org/
    • Email
Re: Mac Menubar
« Reply #3 on: May 16, 2012, 08:27:49 pm »
I don't really know what you want to do, but in any case you can still develop a Cocoa application where you set the menu bar as you want, and then create SFML windows within the Cocoa application.
Want to play movies in your SFML application? Check out sfeMovie!

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Mac Menubar
« Reply #4 on: January 24, 2013, 07:45:08 pm »
I don't really know what you want to do, but in any case you can still develop a Cocoa application where you set the menu bar as you want, and then create SFML windows within the Cocoa application.

Well 8 months down the road and this issue has come up to bite me. Our one game on the Mac App Store, has now been denied an update due to lacking a menu bar, and specifically the ability to click on the App name in the menu bar and select quit.

Has there been any progress on this general issue? If not I guess I'll be trying to embed my game into an existing cocoa window.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #5 on: January 24, 2013, 08:16:57 pm »
unfortunately I haven't had the time to work on this issue yet. So no progress so far.
SFML / OS X developer

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Mac Menubar
« Reply #6 on: January 24, 2013, 09:12:26 pm »
unfortunately I haven't had the time to work on this issue yet. So no progress so far.

Oh well no worries, just wanted to check, before diving off into the deep.

Do you know if I should expect any major issues if I try an use SFML from within a existing cocoa setup? I pretty much just use SMFL for doing the OpenGL context creation and input gathering.

I suppose the biggest headache might just be the event stuff.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #7 on: January 25, 2013, 09:02:34 am »
Events should work the same way (theoretically). If something doesn't just tell me.

The main difficulty I had when writing the cocoa example was to mix C++ and Objective-C. From what I recall there are a few tricks like C++ constructor not being called on C++ attribute in a Objective-C class (use new/delete to workaround that).
SFML / OS X developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Mac Menubar
« Reply #8 on: January 25, 2013, 02:41:37 pm »
You can do it without going deep in sfml, application. Just do it as always.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #9 on: January 25, 2013, 02:43:13 pm »
what do you mean by «as always» ?
SFML / OS X developer

Acrobat

  • Full Member
  • ***
  • Posts: 153
    • View Profile
Re: Mac Menubar
« Reply #10 on: January 25, 2013, 02:59:13 pm »
You can use [NSApplication sharedApplication] in application, as i remember you can add menu there. Am i wrong ?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #11 on: January 25, 2013, 03:07:55 pm »
yes, probably, but wouldn't be easier to use the interface build to do it ? I mean, in any case you need some obj-c object to catch the action so it simpler to design everything in Xcode with some nice drag'n'drops than doing everything in code.
SFML / OS X developer

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Mac Menubar
« Reply #12 on: January 25, 2013, 06:54:52 pm »
Thanks guys, I hadn't even realized there was a cocoa example.  I'll also take a look at the whole  [NSApplication sharedApplication] i've actually never used interface builder, despite doing Obj C and so forth. (Admittedly I try to limit Obj C to the bare minimum.)

zenroth

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Mac Menubar
« Reply #13 on: January 25, 2013, 08:51:53 pm »
Alright this was actually trivial to accomplish it seems.

I just created a little objective c interface to handle my callbacks, set NSApp's delegate to my own callback which SFML doesn't appear to touch, then created a menu and added it via [NSApp setMainMenu:];

I then populated the menu with the standard menu item entries like about, show all, hide, and quit.

I was able to do all of this inside of my own initialization routines and didn't need to mess with nib files or cocoa runloops or anything, in about 40 lines total i'd guess.

Finally wrap the code in a #ifdef for mac platform.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Mac Menubar
« Reply #14 on: January 25, 2013, 10:32:30 pm »
ho nice ! I thought it was more complicated than that. Could you upload the piece of code ?  :)
SFML / OS X developer