SDK:Working with VWPullDownMenuCtrl

From Vectorworks Developer
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

.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 followed by a second "-" to create the seperator.

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) |