Menu button and context menu

Started by Fred Tomke, January 15, 2010, 01:08:07 PM

Previous topic - Next topic

Fred Tomke

Question:

  • How can I set a context menu to a tree item or listview item?
  • How can I create a menu button?
  • How can I show a shortcutmenu with a certain content depending on the clicked item?

Answer:
There is no built-in menubutton control and no popupmenu control in OpenDCL.
But you can workaround that with a static or dynamic shortcutmenu based on a loaded menu.

The attached project demonstrates solutions for all questions above. In every case a popupmenu is needed to be shown by the AutoLISP menucmd-function.

Code (autolisp) Select

(defun c:showmenu ()
  (MENUCMD "P0=MENUBUTTON.MENUBUTTON")
  (MENUCMD "P0=*")
  (princ)
); c:showmenu


The macro of each menu item either calls an event for the dialog or another command.
The menu button changes the current method after selecting a menubutton item.

The select button of this sample invokes a progress of reading all listview items to create a shortcut menu of them.
This sample shows how to handle with a dynamic shortcutmenu.

Many thanks to Barry Ralphs and James Buzbee for their samples.

Note: all the contents of the archive must be placed in a AutoCAD support path. Should work for all AutoCAD releases from R16.0 up to 18.1!

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Fred Tomke

Hello, in the Rev 1.1 of this FAQ I want apply what I have learned when I studied the changes from Owen of my scrollbar sample. Owen put the modified code to the new OpenDCL sample in the folder "C:\Program Files\OpenDCL Studio\<LANGUAGE>\Samples".

What is different? The pb_task_OnClicked event handler was replaced by two commands. The commands will be assigned regarding the latest selected method. Have a look into the code and watch out for the (dcl_Control_SetProperty menubutton_form_pb_task "Clicked" ...)-lines.

Have fun with it.
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]