dawenxi-tech / 2fa

A 2FA desktop application.
MIT License
2 stars 1 forks source link

desktop menus - low priority. #12

Open gedw99 opened 9 months ago

gedw99 commented 9 months ago

Just a thought for later, but I think can adapt this to have menus for gio desktop apps later too.

The same mechanism that shows a menu in the tray can be adapted to show menus for a gio desktop app perhaps. Lets see when we get to it.

heramerom commented 9 months ago

Yeah, I was a iOS developer many years ago and has a little macos dev experience.

In macos or ios develop, an application is a singleton instance, it can only has one delegate. When systray runs, it will set a delegate and when gio runs, it also set a delegate, that conflict. So it will run into mess some time.

And in my case, I was modify Gio source code to add a GioAppDelegate property and set property value later use NSObject performSelector:withObject: api.

@interface GioAppDelegate : NSObject<NSApplicationDelegate>
@property (nonatomic, strong) NSStatusItem *statusItem;
@end

[delegate performSelector:@selector(setStatusItem:) withObject:statusItem];

In fact, we can even do not change Gio source code, That is use the class_addProperty Api, https://stackoverflow.com/questions/7819092/how-can-i-add-properties-to-an-object-at-runtime, but that was not suggest by Apple.

Btw, the statusItem must as a delegate's property so it will appear in menu bar. That cost me a lot of time to find out reason? https://stackoverflow.com/a/54773268

gedw99 commented 9 months ago

I’m glad you think it’s a decent idea.

iOS and Mac development is not my think . I do golang for frontend and bsckend.