Menu Popup explanation
Publicado: Jue Mar 17, 2005 11:15 am
Hi,
In the statusbar of my app I've added a panel to switch language of
application as you see in attached image.
In the OnInitialize event I use this code
// Status bar
WITH OBJECT ::oBackStatus
:oImageList:Add( "BMP_LANGUAGE" )
:oImageList:Add( "BMP_CHG_OFF" )
:oImageList:Add( "BMP_CHG_ON" )
:aItems[ tSTATUS_LANG ]:nImage := 1
:aItems[ tSTATUS_LANG ]:OnClick := { |oSender, x, y| ::FormLanguageSelect( oSender, x, y ) }
END WITH
This is the methods used to activate popup menu
METHOD FormLanguageSelect( oSender, x, y ) CLASS TBackup
LOCAL oMenu AS OBJECT
oMenu := GetLanguagePopupMenu( Self )
IF !( oMenu == NIL )
ACTIVATE POPUP oMenu OF Self AT y, x
ENDIF
RETURN Nil
These are the two functions that actually build the popup menu
//---------------------------------------------------------- --------------------
// Return language popup menu
//
FUNCTION GetLanguagePopupMenu( oDlg )
LOCAL aLang AS ARRAY
LOCAL oRetval AS OBJECT
LOCAL nI, nLen AS NUMERIC
aLang := GetLanguages()
nLen := Len( aLang )
IF ( nLen > 0 )
oRetval := TMenu():Create( oDlg, TRUE )
FOR nI := 1 TO nLen
WITH OBJECT TMenuItem():New( oRetval )
:cText := aLang[ nI, 2 ]
:OnClick := GetLanguagePopupMenuAction( oDlg, aLang[ nI, 2 ] )
:Create()
END WITH
NEXT
ENDIF
RETURN oRetval
//---------------------------------------------------------- --------------------
// Return language popup action for single language
//
FUNCTION GetLanguagePopupMenuAction( oDlg, nID )
RETURN {|| oDlg:BackLanguage( nID, FALSE ) }
If I trace through the debugger the popup menu is built correctly but the
call to ACTIVATE POPUP doesn't show anything and returns immediatly.
Any hints ? What am I doing wrong ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
--
In the statusbar of my app I've added a panel to switch language of
application as you see in attached image.
In the OnInitialize event I use this code
// Status bar
WITH OBJECT ::oBackStatus
:oImageList:Add( "BMP_LANGUAGE" )
:oImageList:Add( "BMP_CHG_OFF" )
:oImageList:Add( "BMP_CHG_ON" )
:aItems[ tSTATUS_LANG ]:nImage := 1
:aItems[ tSTATUS_LANG ]:OnClick := { |oSender, x, y| ::FormLanguageSelect( oSender, x, y ) }
END WITH
This is the methods used to activate popup menu
METHOD FormLanguageSelect( oSender, x, y ) CLASS TBackup
LOCAL oMenu AS OBJECT
oMenu := GetLanguagePopupMenu( Self )
IF !( oMenu == NIL )
ACTIVATE POPUP oMenu OF Self AT y, x
ENDIF
RETURN Nil
These are the two functions that actually build the popup menu
//---------------------------------------------------------- --------------------
// Return language popup menu
//
FUNCTION GetLanguagePopupMenu( oDlg )
LOCAL aLang AS ARRAY
LOCAL oRetval AS OBJECT
LOCAL nI, nLen AS NUMERIC
aLang := GetLanguages()
nLen := Len( aLang )
IF ( nLen > 0 )
oRetval := TMenu():Create( oDlg, TRUE )
FOR nI := 1 TO nLen
WITH OBJECT TMenuItem():New( oRetval )
:cText := aLang[ nI, 2 ]
:OnClick := GetLanguagePopupMenuAction( oDlg, aLang[ nI, 2 ] )
:Create()
END WITH
NEXT
ENDIF
RETURN oRetval
//---------------------------------------------------------- --------------------
// Return language popup action for single language
//
FUNCTION GetLanguagePopupMenuAction( oDlg, nID )
RETURN {|| oDlg:BackLanguage( nID, FALSE ) }
If I trace through the debugger the popup menu is built correctly but the
call to ACTIVATE POPUP doesn't show anything and returns immediatly.
Any hints ? What am I doing wrong ?
--
Best regards,
Giuseppe Bogetti
B.G. Soft
Cuneo - Italy
--