Re: Dialog Command Keys
Re: Dialog Command Keys
- Subject: Re: Dialog Command Keys
- From: Raleigh Ledet <email@hidden>
- Date: Wed, 27 Jul 2011 11:39:20 -0700
The target of the menus should be nil and you need to set the action to what standard controls expect them to be. Namely:
cut: @selector(cut:)
copy: @selector(copy:)
paste: @selector(paste:)
so basically:
[cutMenuItem setTarget:nil]
[cutMenuItem setAction:@selector(cut:)]
This of course means that you also have to rename your custom handler to also have the same name. Or, you can do the following:
- (void)cut:(id)sender {
[self mySpecialCutHandler];
}
-raleigh
On Jul 27, 2011, at 11:26 AM, Bill Appleton wrote:
> hi all,
>
> oh man i hate to belabor this issue but i have studied every suggestion and
> the docs and i cannot figure this out
>
> the problem is that i cannot get command keys to work on dialog text, even
> dialogs run and managed by cocoa
>
> as suggested i set the target for my menu items to nil, and also made sure
> that in my app menu bar the needed items were active
>
> after doing this when a dialog is up and you cut text you see the menu
> flash, there is no beep, but the text is still not cut
>
> if a dialog is not up and you hit command-x you also see the menu flash and
> there is no beep, so this was perhaps imaginary progress
>
> i have various other windows in my app for text editing and all of them work
> fine and get their command keys no problem
>
> in textedit for example the text in the open file dialog can be edited with
> the app menu, and the menu reacts to the text, for example you can't cut if
> there is no selection
>
> my menus have setAutoEnablesItems:NO and i enable them as needed but they
> are enabled when dialogs are up
>
> i'm not sure the issues raised so far are related to the problem. its as if
> the dialogs in my app are not in the responder chain for key events
>
>
> best
>
> bill
>
>
>
>
>
>
>
>
>
>
>
> On Tue, Jul 26, 2011 at 10:44 AM, Kyle Sluder <email@hidden> wrote:
>
>> On Tue, Jul 26, 2011 at 10:30 AM, Bill Appleton
>> <email@hidden> wrote:
>>> hi all
>>>
>>> i set the target and the action on my menu items -- this is so that i can
>>> get my handler called when someone selects a menu item
>>> i will re-read the event handler docs with regard to menu items (no
>> keyboard
>>> issues) and see if that helps
>>
>> Ah, there's your problem. You need to set these targets to nil, which
>> is equivalent to wiring them up to First Responder in a nib.
>>
>> --Kyle Sluder
>>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden