Pieter van Dieren
14-Aug-2009, 04:56 AM
I needed to add a Checkbox item to a context menu.
An easy way (without having to create a subclass which uses IsChecked etc) would be to have the following method available in cSigCjContextMenu :
{ DesignTime=False }
Procedure Set Checked String sCaption Boolean bState
Integer iArraySize iCount iIndex
Handle hoMenuItem
String[][] saMenuItem
String sMenuItem
Get psaMenuItem to saMenuItem
Move (SizeOfArray(saMenuItem)) to iArraySize
For iCount from 0 to (iArraySize-1)
Move saMenuItem[iCount][0] to sMenuItem
Move saMenuItem[iCount][1] to hoMenuItem
If (sMenuItem = sCaption) Begin
Set pbChecked of hoMenuItem to bState
End
Loop
End_Procedure
Sample usage:
Object oSigCJContextMenu is a cSigCJContextMenu
Property Boolean pbItemChecked False
// DoToggleItem
Procedure DoToggleItem
Boolean bChecked
Move (not(pbItemChecked(Self))) to bChecked
Set pbItemChecked to bChecked
Set Checked to "Item with checkbox" bChecked
// Do whatever else you need to do
Set Visible_State of oObject to bChecked
End_Procedure
Send Add_MenuItem "Item with checkbox" "DoToggleItem" True ""
End_Object
Perhaps you guys could add this?
An easy way (without having to create a subclass which uses IsChecked etc) would be to have the following method available in cSigCjContextMenu :
{ DesignTime=False }
Procedure Set Checked String sCaption Boolean bState
Integer iArraySize iCount iIndex
Handle hoMenuItem
String[][] saMenuItem
String sMenuItem
Get psaMenuItem to saMenuItem
Move (SizeOfArray(saMenuItem)) to iArraySize
For iCount from 0 to (iArraySize-1)
Move saMenuItem[iCount][0] to sMenuItem
Move saMenuItem[iCount][1] to hoMenuItem
If (sMenuItem = sCaption) Begin
Set pbChecked of hoMenuItem to bState
End
Loop
End_Procedure
Sample usage:
Object oSigCJContextMenu is a cSigCJContextMenu
Property Boolean pbItemChecked False
// DoToggleItem
Procedure DoToggleItem
Boolean bChecked
Move (not(pbItemChecked(Self))) to bChecked
Set pbItemChecked to bChecked
Set Checked to "Item with checkbox" bChecked
// Do whatever else you need to do
Set Visible_State of oObject to bChecked
End_Procedure
Send Add_MenuItem "Item with checkbox" "DoToggleItem" True ""
End_Object
Perhaps you guys could add this?