[Mono-osx] Control and Mac key

Borja Ruiz Arroyo bruiz at codicesoftware.com
Tue Mar 24 06:53:38 EDT 2009

Matt Emson escribió:
> Borja Ruiz Arroyo wrote:
>> Thanks Matt,
  >> As I have seen when I tried (using X11) the mac (apple) key haven't
>> got the windows ctrl key behavior as it should.
> X11 isn't Mac OS X, it's a layer on top. You might find that this is the 
> issue?

I specified that i was using X11 because the behavior may be different 
with it.

>> I have custom controls which have functionality with ctrl key. In 
>> order to know if this key is pressed I use Control.ModifierKeys or 
>> KeyEventArgs.Control, but in Mac i have to check mac key instead of 
>> control key but it doesn't exist. How can i do that?
> I assume you are using WinForms - I don't have much experience with 
> WinForms under Mono. I've avoided it as it isn't portable enough to make 
> all the shortfalls worthwhile.
>> I can save the status of the mac key when pressed (key down)and update 
>> it when released (key up), and use this status like I was using 
>> ModifierKeys when the application is running in a Mac OS. But i was 
>> looking for an easy way to do that, how can i do?
> I'm not really sure what you want or mean here. Can you give more of a 
> (code) example? Of how it "works" and how it also "fails"? I'm not sure 
> if you are now saying that the key is detected correctly in the KeyXxx 
> events, or that you are using some kind of work around? It sounds more 
> like a bug in Mono if two different API calls/functions in the .Net 
> framework give different values for the same key press event.

Yes I was using WinForms as base, but I use custom controls over them.
I was using ctrl key for example to allow a multi selection, but in mac 
it has to be done using the mac key. In order to detect the 
multiselection I use something like:

if (e.KeyCode == Keys.ControlKey)
     multiSelectMode = MultiSelectMode.Selective;

I could change the condition for e.Control

But in mac I have to check the mac key, which it's received like the alt 
key as I have seen (in KeyModifiers, not in KeyCode and Alt key it's not 
received in ModifierKeys) .

I have to use ctrl key in mac for Right-click emulation with 
Control-click, and let the user do the operations (select all, 
multiselect, copy,...) as he is used to do in mac (mac + key and not 
ctrl + key).

In this way, Do you know a easy way to do the right click emulation? (To 
don't show it manually)



More information about the Mono-osx mailing list