Method FindItem( nId ) added

This commit is contained in:
Antonio Linares
2001-09-01 17:05:39 +00:00
parent 177c4bb36b
commit 5e17b8686c
2 changed files with 43 additions and 4 deletions

View File

@@ -59,8 +59,9 @@ CLASS TMenu
DATA nHandle
DATA aItems
METHOD New( oForm )
METHOD Add( oMenuItem )
METHOD New( oForm ) // Creates a new menu
METHOD Add( oMenuItem ) // Adds a menuitem
METHOD FindItem( nId ) // Searches for a sub menuitem given its id
ENDCLASS
@@ -80,3 +81,21 @@ METHOD Add( oMenuItem ) CLASS TMenu
AAdd( ::aItems, oMenuItem )
return nil
METHOD FindItem( nId ) CLASS TMenu
local oMenuItem, n
for n = 1 to Len( ::aItems )
if ( oMenuItem := ::aItems[ n ] ):nId == nId
return oMenuItem
else
if oMenuItem:aItems != nil
if ( oMenuItem := oMenuItem:FindItem( nId ) ) != nil
return oMenuItem
endif
endif
endif
next
return oMenuItem

View File

@@ -57,7 +57,8 @@
CLASS TMenuItem
DATA cCaption // Specifies the text of the menu item
DATA cAction // A character description of the method to invoke
DATA cName // The name of this component
DATA OnClick // A character description of the method to invoke
DATA nId // Command value to send to the container form
DATA lEnabled // Specifies whether the menu item is enabled
DATA aItems // Contains the menu items in the submenu of the menu item
@@ -68,6 +69,7 @@ CLASS TMenuItem
METHOD New( oOwner ) // Creates a new menu item
METHOD Add( oMenuItem ) // Adds a new drop down menu item
METHOD FindItem( nId ) // Searches for a sub menuitem given its id
ENDCLASS
@@ -93,4 +95,22 @@ METHOD Add( oMenuItem ) CLASS TMenuItem
oMenuItem:oParent = Self
AAdd( ::aItems, oMenuItem )
return nil
return nil
METHOD FindItem( nId ) CLASS TMenuItem
local oMenuItem, n
for n = 1 to Len( ::aItems )
if ( oMenuItem := ::aItems[ n ] ):nId == nId
return oMenuItem
else
if oMenuItem:aItems != nil
if ( oMenuItem := oMenuItem:FindItem( nId ) ) != nil
return oMenuItem
endif
endif
endif
next
return oMenuItem