It is currently Mon May 20, 2019 6:04 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Open ComboBoxGadget?
PostPosted: Mon Mar 11, 2019 2:56 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 395
Hi,

Is it possible to force a ComboBoxGadget to open using CocoaMessage?

I don't know if it's the right function, but I've found performClick in NSPopUpButtonCell. I don't know how to get access to it, nor what I would specify for "frame" and "controlView", however.

Thank you for any suggestions.


Top
 Profile  
Reply with quote  
 Post subject: Re: Open ComboBoxGadget?
PostPosted: Mon Mar 11, 2019 7:17 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3339
Location: Netherlands
You can perform a click on the gadget itself put when I tried the gadget closed immediately after opening. :?
Code:
CocoaMessage(0, GadgetID(MyComboGadget), "performClick:", 0)

_________________
macOS 10.14 Mojave, PB 5.62 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: Open ComboBoxGadget?
PostPosted: Mon Mar 11, 2019 8:25 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2211
Location: Singapore
wilbert wrote:
You can perform a click on the gadget itself put when I tried the gadget closed immediately after opening. :?
Code:
CocoaMessage(0, GadgetID(MyComboGadget), "performClick:", 0)

It works perfectly on High Sierra.

_________________
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Open ComboBoxGadget?
PostPosted: Mon Mar 11, 2019 8:45 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1603
Location: Germany
You have to use two different methods to programmatically open a non-editable ComboBox (NSPopUpButton) or an editable ComboBox (NSComboBox). I have tested the following example successfully on these MacOS versions:
- MacOS 10.6.8 'Snow Leopard' with PB 5.46 x86 in ASCII and Unicode mode
- MacOS 10.9.5 'Mavericks' with PB 5.46 x86 in ASCII and Unicode mode
- MacOS 10.13.6 'High Sierra' with PB 5.46 x64 in ASCII and Unicode mode
Code:
EnableExplicit

Define i.I
Define Selector.I = sel_registerName_("popUp:")

OpenWindow(0, 270, 100, 200, 200, "ComboBoxGadgets")
ComboBoxGadget(0, 10, 20, WindowWidth(0) - 20, 25)
ComboBoxGadget(1, 10, 70, WindowWidth(0) - 20, 25, #PB_ComboBox_Editable)
ButtonGadget(2, 10, 130, WindowWidth(0) - 20, 25, "Open 1st ComboBox")
ButtonGadget(3, 10, 160, WindowWidth(0) - 20, 25, "Open 2nd ComboBox")

For i = 1 To 3
  AddGadgetItem(0, -1, "Item " + Str(i))
  AddGadgetItem(1, -1, "Editable item " + Str(i))
Next

SetGadgetState(0, 0)
SetGadgetState(1, 0)

Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
      Break
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 2
          CocoaMessage(0, GadgetID(0), "performClick:", 0)
        Case 3
          CocoaMessage(0, CocoaMessage(0, GadgetID(1), "cell"),
            "performSelector:", Selector)
      EndSelect
  EndSelect
ForEver


Top
 Profile  
Reply with quote  
 Post subject: Re: Open ComboBoxGadget?
PostPosted: Mon Mar 11, 2019 11:16 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 395
Thank you, all.

I guess I was overthinking it. :oops:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye