It is currently Fri May 24, 2013 12:19 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Enable AutoSort in ComboBoxGadget
PostPosted: Sun Apr 10, 2011 1:57 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 814
Location: Germany
If you are in need to display the entries of your ComboBox in sorted
order, MacOS X 10.2 and later offers you the possibility to automatically
sort your ComboBox items. Another goodie in the following example
code demonstrates how to programmatically open the drop down list of
your ComboBox. Unfortunately the example only works for editable
ComboBoxes (with the flag #PB_ComboBox_Editable) because the
underlying API element is a HIComboBox which offers the described
features. PB's non-editable ComboBox utilizes a PopupButton control
which doesn't support these features.
Code:
ImportC ""
  HIComboBoxChangeAttributes(HIViewRef.L, AttributesToSet.L, AttributesToClear.L)
  HIComboBoxSetListVisible(HIViewRef.L, Visible.L)
EndImport

#kHIComboBoxAutoSortAttribute = 1 << 2

OpenWindow(0, 200, 100, 200, 130, "ComboBoxGadget")
ComboBoxGadget(0, 10, 10, WindowWidth(0) - 20, 100, #PB_ComboBox_Editable)

; ----- Activate ComboBox AutoSort Feature

HIComboBoxChangeAttributes(GadgetID(0), #kHIComboBoxAutoSortAttribute, 0)

; ----- Add unsorted entries

AddGadgetItem(0, -1, "Entry 2")
AddGadgetItem(0, -1, "Entry 4")
AddGadgetItem(0, -1, "Entry 3")
AddGadgetItem(0, -1, "Entry 1")

; ----- Open drop down list programmatically

HIComboBoxSetListVisible(GadgetID(0), #True)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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