Dragan,

> On Oct 19, 2022, at 15:46, Dragan Milić via Cocoa-dev 
> <cocoa-dev@lists.apple.com> wrote:
> 
> 
>> 
>> On 19. 10. 2022., at 03:52, Eric Schlegel  wrote:
>> 
>> 
>> I can tell you that the Help menu does itself use makeFirstResponder: on the 
>> text view…
> 
> Eric, thanks for detailed explanation and willingness to help. Your message 
> triggered me to play with the issue a bit more and I figured out what the 
> problem is. But I also realised  I’ve come to some wrong conclusions before, 
> so I want to correct myself as well so that nobody here is left confused by 
> them. I’ll do that first…
> 
>> On 18. 10. 2022., at 18:43, Dragan Milić wrote:
>> 
>> This issue isn’t related to the menu being attached to the NSStatusItem, it 
>> also happens in the main and/or contextual menu within the application. I’d 
>> eventually want to set the focus on the text field programmatically each 
>> time the menu appears, but that’s not possible either.
> 
> This was something I observed quite some time ago and I admin I haven’t 
> confirmed it again before I sent my initial message here. God knows what I 
> did wrong at that time, but I can say my above statement is completely false! 
> Placing NSTextFiend inside NSMenuItem works fine in both main and contextual 
> menus in the application. The text field gets focus when the menu opens, 
> sending -[NSWindow makeFirstResponder:] is not even necessary.
> 
> Now, my problem is that the application is defined as LSUIElement=YES (or its 
> activation policy is programmatically set to 
> NSApplicationActivationPolicyAccessory), meaning it doesn’t show its icon in 
> the Dock, it doesn’t show its main menu, nor can it be made active with 
> alt+tab. As known, clicking the status item of any application and making its 
> status item menu visible, doesn’t really make the application active, and in 
> my case that affect functionality of the text item. So, when I click on the 
> status item and show the status item menu, the application is not really 
> active

I have a status item and in order to get it to show I have to call this in my 
code that orders in the view/window

    [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]

I have no idea if this is the best way to accomplish this, but it works for me…

I can also add that status items used to be pretty easy to work with but Apple 
made this significantly harder over the years…. I see applications that have 
accompanying status items that work, better than mine… but I haven’t been able 
to figure it out any better than what I have…

Sandor

> and hence is text field (kind of) disabled, not being able to receive events. 
> If I set application’s activation policy to 
> NSApplicationActivationPolicyRegular and make it active (clicking on its icon 
> in the Dock or alt+tabbing) before I click its status item, the status item 
> menu appears with the text field active and focused, ready to be typed into.
> 
> I haven’t find the complete solution yet. Sending -[NSApp 
> activateIgnoringOtherApps:YES] does the job partially; clicking the status 
> item and opening its menu results in the application being activated, but 
> that automatically closes the menu immediately upon being open. But the 
> application stays active, so clicking the status item again finally opens the 
> menu with the text field active and having focus. If anyone have any idea how 
> to solve this, I’d be thankful to hear it.
> 
> -- Dragan
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari....@gmail.com
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to