Cross Platform MessageRequester

Share your advanced PureBasic knowledge/code with the community.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Cross Platform MessageRequester

Post by wilbert »

Keya wrote:The following is a mashup mostly based on code in this thread but also some by wilbert to add Mac OSX support, although the Mac part doesn't support the ability to specify a parent window (it seems the NSAlert object doesnt have that capability?)
You can set a parent window on OSX but I don't know if it is used a lot and haven't tested it on older versions of OSX.

Code: Select all

CocoaMessage(0, CocoaMessage(0, Alert, "window"), "setParentWindow:", WindowID(#ParentWindow))
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Cross Platform MessageRequester

Post by Keya »

wilbert i did try setParentWindow when i was writing it but it seemed to be complaining that NSAlert didnt support it, so it seems thats just for regular dialogs? retrying now to confirm

[Update] It seems to be working fine, i think it's just because when i was trying it i didn't have that second embedded CocoaMessage so i was throwing the bone to the wall not the dog :)
Code updated! Many thanks again!!!
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Cross Platform MessageRequester

Post by wilbert »

Keya wrote:i think it's just because when i was trying it i didn't have that second embedded CocoaMessage
That's exactly it. You need to use the window property of the alert object.
It's funny what you can do with it. For example also changing the background color of the alert. :)

Code: Select all

CocoaMessage(0, CocoaMessage(0, Alert, "window"), "setBackgroundColor:", CocoaMessage(0, 0, "NSColor yellowColor"))
Windows (x64)
Raspberry Pi OS (Arm64)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Cross Platform MessageRequester

Post by davido »

Thank you for sharing, excellent.
DE AA EB
Post Reply