Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-09

What conditional define can I use to cover all LCL programs on Mac (Classic or OS X)?

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

Hi,

In some TMaskEdit component I hardcoded the use of the Ctrl-key in KeyDown. I understand that on a Mac in this situation the Meat key should be used.

Now I want to do something like this:

const
  {$ifdef allpossiblemacplatforms}
  ssModifier = ssMeta;
  {$else}
  ssModifier = ssCtrl;
  {$endif}

What define should I use for the {$ifdef allpossiblemacplatforms} part?

The alternative would be to write widgetset implementations for the controls KeyDown procedure, which seems a little bit overkill to me.

Bart

Reply by email

Felipe Monteiro de Carvalho
to Bart

Just go for {$ifdef darwin} which means Mac OS X and also iOS (I think)

I find it extremely unlikely that you are going to compile for the old Mac OS, but if you really want to, then:

{$if defined(darwin) or defined(macos)}
  {$define allmacosplatforms}
{$endif}
Felipe Monteiro de Carvalho

Reply by email

Mattias Gaertner
to Felipe Monteiro de Carvalho
Having said that, the LCL should probably have a constant for this ... maybe we should add that to the LCL if it doesn't already exist. Suggestions for a good name would be good.

You have already given the defines. What other define do you need?

Mattias

Reply by email

Felipe Monteiro de Carvalho
to Mattias Gaertner
Mattias Gaertner wrote
You have already given the defines. What other define do you need?

Not define, constant. I said that it would be interresting to add a constant to the LCL which is ssMeta in Mac OS X and ssCtrl in all other platforms. Looks useful to implement Ctrl+C (in Mac it is Meta+C) for example in a custom control.

Felipe Monteiro de Carvalho

Reply by email

Bart
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Not define, constant. I said that it would be interresting to add a constant to the LCL which is ssMeta in Mac OS X and ssCtrl in all other platforms. Looks useful to implement Ctrl+C (in Mac it is Meta+C) for example in a custom control.

I have been informed that it is possible for a Mac computer to alos have a Ctlr key on the keyborad (besides the Meta). If this is indeed the case, then such a solution would not work?

Bart

Reply by email

Bart
to Felipe Monteiro de Carvalho: Just go for {$ifdef darwin} which means Mac OS X and also iOS (I think) I find it…
Felipe Monteiro de Carvalho wrote 9 lines
Just go for {$ifdef darwin} which means Mac OS X and also iOS (I think) I find it extremely unlikely that you are going to compile for the old Mac OS, but if you really want to, then: {$if defined(darwin) or defined(macos)} {$define allmacosplatforms} {$endif}

I agree that it is extremely uinlikely that I would compile for Mac OS Classic, especially since I do not have (access to) a Mac ;-)

The code will be part of the LCL, so others might though...

Anyway thanks for the solution.

I am unfamiliar with the "new" {$if defined(x) or defined(y)} syntax (as opposed to the "old" {$ifdef x}), so already I learned 2 things today.

Bart

Reply by email

Felipe Monteiro de Carvalho
to Bart: On 9/4/11, Felipe Monteiro de Carvalho I have been informed that it is possible for a Mac…
Bart wrote
I have been informed that it is possible for a Mac computer to alos have a Ctlr key on the keyborad (besides the Meta). If this is indeed the case, then such a solution would not work?

The presence of a Control key in my Mac Book does not change the fact that common operations are performed via the Meta key.

One issue with adding this constant to the LCL is that it's natural place seams to be the RTL, since ssCtrl is defined there.

Felipe Monteiro de Carvalho

Reply by email

Bart
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 8 lines
On Sun, Sep 4, 2011 at 10:49 AM, Bart wrote: > I have been informed that it is possible for a Mac computer to alos > have a Ctlr key on the keyborad (besides the Meta). > If this is indeed the case, then such a solution would not work? The presence of a Control key in my Mac Book does not change the fact that common operations are performed via the Meta key.

Yep, my reply doesn't make much sense (Oops).

Bart

Reply by email