Difference between revisions of "SDK:Working with VWPullDownMenuCtrl"

From Vectorworks Developer
Jump to: navigation, search
(Adding separators)
m (added example code.)
 
Line 56: Line 56:
 
pPopupCtrl->AddItem( "-" );
 
pPopupCtrl->AddItem( "-" );
 
pPopupCtrl->AddItem( "item3" );
 
pPopupCtrl->AddItem( "item3" );
 +
</code>
  
If you need to add a seperator on a level in an enhanced pull down, you need to add "- -". The first "-" is to create the "level", then a space followed by a second "-" to create the seperator.
+
If you need to add a seperator on a level in an enhanced pull down, you need to add "- -". The first "-" is to create the "level", then a space (don't forget this one) followed by a second "-" to create the seperator.
  
 +
<code lang="cpp">
 +
pPopupCtrl->AddItemEnhanced(  "item1-sub1", "", 0 );
 +
pPopupCtrl->AddItemEnhanced(  "item1- -", "", 1);
 +
pPopupCtrl->AddItemEnhanced(  "item1-sub2", "", 0);
 
</code>
 
</code>
  

Latest revision as of 10:48, 3 December 2015

.SDK|SDK ..SDK:Types|SDK Types ..SDK:Using the SDK|Using the SDK ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Initializing of the control

The initialization of the control is done in OnSetUpEvent:

void CSampleDlg::OnSetUpEvent()
{
	VWDialog::OnSetUpEvent();

	VWPullDownMenuCtrl*  pPopupCtrl  = this->GetPullDownMenuCtrlByID( kMyListBox );

	pPopupCtrl->AddItem( "item1" );
	pPopupCtrl->AddItem( "item2" );
}

Settings markers to the items

You can assign marker value to each element in the popup list. This helps managing dynamicly changed popup lists.

The simplest example is making a popup list for enumerations, but having dynamic sub set of the enumeration as items in the popup list:

enum EMyValues {
  kMyValues_One,
  kMyValues_Two,
  kMyValues_Three
  kMyValues_Four,
}
 
pPopupCtrl->AddItem( "item1", size_t(-1), kMyValues_One );
pPopupCtrl->AddItem( "item3", size_t(-1), kMyValues_Three );
 
EMyValues myValue = ...;
 
// select appropreate item
// Actually the enumeration value is used
pPopupCtrl->SelectItemWithMarker( myValue );

Then, we could easily map backward from the selection index to enumeration value:

EMyValues myValue = (EMyvalues) pPopupCtrl->GetSelectedItemMarker();

Adding separators

By adding a "-", a not selectable separator is added to the list in the pull down.

pPopupCtrl->AddItem( "item1" );
pPopupCtrl->AddItem( "-" );
pPopupCtrl->AddItem( "item3" );

If you need to add a seperator on a level in an enhanced pull down, you need to add "- -". The first "-" is to create the "level", then a space (don't forget this one) followed by a second "-" to create the seperator.

pPopupCtrl->AddItemEnhanced(  "item1-sub1", "", 0 );
pPopupCtrl->AddItemEnhanced(  "item1- -", "", 1);
pPopupCtrl->AddItemEnhanced(  "item1-sub2", "", 0);

See Also

SDK:Creating handler class for VectorScript layout dialog | SDK:Creating handler class for manual layout dialog | SDK:Working with Dynamic Data Exchange (DDX) |

Personal tools
NamespacesFFFF

Variants
Actions
Advanced Search
See Also
Navigation
Toolbox