Page 1 of 2
Buttonbar 2007 button with a attached Popup menu
Posted: Wed Oct 24, 2007 7:24 pm
by Otto
Does someone know how to open the attached popup menu with a click on the button.
(Like in WORD Button: “Formatvorlagen”)
Regards,
Otto
Posted: Wed Oct 24, 2007 11:12 pm
by nageswaragunupudi
Code: Select all
DEFINE BUTTON OF oBar NOBORDER ;
PROMPT 'SubMenu' ;
MENU MyPopUp() ;
ACTION MsgInfo('Can have action and also submenu')
....
....
// -------------------
STATIC FUNCTION MyPopUp()
LOCAL oPop
MENU oPop POPUP
MENUITEM 'One'
MENUITEM 'Two'
ENDMENU
RETURN oPop
Posted: Thu Oct 25, 2007 7:20 am
by Otto
nageswaragunupudi , thank you for your answer.
But that is the code how to attach a popup menu.
But I need to open the attached popup menu with a click on the button.
(Like in WORD Button: “Formatvorlagen”)
Here a jpg:
Posted: Thu Oct 25, 2007 9:22 am
by Antonio Linares
Otto,
Please add this method to class TBtnBmp:
Code: Select all
METHOD ShowPopup() CLASS TBtnBmp
local oWnd
if ::oPopup != nil
if ::oWnd:oWnd != nil .and. Upper( ::oWnd:oWnd:Classname() ) == "TBAR"
oWnd := ::oWnd:oWnd
else
oWnd := ::oWnd
endif
if GetClassName( GetParent( Self:hWnd ) ) != "TBAR"
oWnd = oWndFromhWnd( GetParent( Self:hWnd ) )
endif
oWnd:NcMouseMove() // close the tooltip
oWnd:oPopup = ::oPopup
::oPopup:Activate( ::nTop + ::nHeight(), ::nLeft, oWnd, .f. )
oWnd:oPopup = nil
::Refresh()
endif
return nil
To use it, simply do:
Code: Select all
MENU oPopup POPUP
MENUITEM "One" ACTION MsgInfo( 1 )
MENUITEM "Two" ACTION MsgInfo( 2 )
ENDMENU
DEFINE BUTTON oBtn OF oBar ACTION oBtn:ShowPopup() ;
RESOURCE "people" PROMPT "Clients" GROUP ;
MENU oPopup
Posted: Thu Oct 25, 2007 1:46 pm
by Otto
Thank you, Antonio.
It is working.
Regards,
Otto
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 8:53 am
by Otto
Hello Antonio,
I have seen that popup is included in 10.3. Thank you.
How can I align the popup menu if I use oBtn:ShowPopup()?
Best regards,
Otto
Code: Select all
@ 5, 145 ADD BUTTON oBtnBearbeiten GROUP oFunktionen BITMAP ".\bitmaps2\11.bmp" MENU oMenuBearbeiten ;
SIZE 65, 75 PROMPT "Bearbeiten" SPLITPOPUP TOP ROUND ;
ACTION ( oBtnBearbeiten:ShowPopup() )
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 9:53 am
by Antonio Linares
Otto,
I don't exactly understand what you mean
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 11:10 am
by nageswaragunupudi
Mr Antonio.
ShowPopup was already there in the FWH long time back.
This kind of code was working since many versions of FWH. I think we do not need to add the above code again:
The code below is an extract from testxbr3.prg:
Code: Select all
DEFINE BUTTON OF oBar ;
RESOURCE "REPORT" TOP ;
PROMPT "Report" ;
MENU ReportMenu( oBrw ) ;
ACTION This:ShowPopUp() ;
MESSAGE "Print the browse contents" ;
TOOLTIP { "Print Report", "Report" }
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 3:39 pm
by Otto
Hello Antonio,
Best regards,
Otto
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 9:01 pm
by Antonio Linares
Otto,
Does it fit in the right side ?
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Wed Apr 07, 2010 9:29 pm
by Otto
Antonio,
yes it fits in the right side.
Best regards,
Otto
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Thu Apr 08, 2010 10:25 am
by Antonio Linares
Otto,
Then it means that the left coordinate of the popup is wrongly calculated.
We are going to review it, thanks
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Thu Apr 08, 2010 10:30 pm
by Daniel Garcia-Gil
Hello Otto...
in METHOD LButtonUp( nRow, nCol ) CLASS TRBtn
find and replace this section...
Code: Select all
case ::nTypeButton == TYPE_SPLITPOPUP
if nRow >= ::nPopupMargin .or. ! lAction
oWnd := ::oWnd
oWnd:NcMouseMove() // close the tooltip
oWnd:oPopup = ::oPopup
::oPopup:Activate( ::nHeight, 0, Self, .F. )
oWnd:oPopup = nil
::Refresh()
else
::click()
endif
case ::nTypeButton == TYPE_POPUP
if nCol >= ::nPopupMargin .or. !lAction
oWnd := ::oWnd
oWnd:NcMouseMove() // close the tooltip
oWnd:oPopup = ::oPopup
::oPopup:Activate( ::nHeight, 0, Self, .F. )
oWnd:oPopup = nil
::Refresh()
else
::click()
endif
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Fri Apr 09, 2010 6:54 am
by Otto
Hello Daniel,
thank you for your help.
I did a short test but the code does not resolve my problem.
If I change as well showpopup() (left + 500) this way I would get the right alignment – only for this special case.
Thanks in advance
Otto
Code: Select all
METHOD ShowPopup() CLASS TRBtn
local oWnd
msginfo("asdfla")
if ::oPopup != nil
if GetClassName( GetParent( Self:hWnd ) ) != "TBAR"
oWnd = oWndFromhWnd( GetParent( Self:hWnd ) )
endif
oWnd:NcMouseMove() // close the tooltip
oWnd:oPopup = ::oPopup
::oPopup:Activate( ::nTop + ::nHeight(), ::nLeft - oWnd:nLeft + 500, oWnd, .f. )
oWnd:oPopup = nil
::Refresh()
endif
return nil
//----------------------------------------------------------------------------//
Re: Buttonbar 2007 button with a attached Popup menu
Posted: Sun Apr 11, 2010 7:50 pm
by Otto
Hello Daniel,
Would you be so kind to have another look at this problem?
Best regards,
Otto