Buttonbar 2007 button with a attached Popup menu

User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Buttonbar 2007 button with a attached Popup menu

Post 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
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Post 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
Regards

G. N. Rao.
Hyderabad, India
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post 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:
ImageImage
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Thank you, Antonio.
It is working.
Regards,
Otto
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post 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() )
Image

Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Antonio Linares »

Otto,

I don't exactly understand what you mean
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post 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" }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Otto »

Hello Antonio,
Best regards,
Otto


Image
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Antonio Linares »

Otto,

Does it fit in the right side ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Otto »

Antonio,
yes it fits in the right side.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Antonio Linares »

Otto,

Then it means that the left coordinate of the popup is wrongly calculated.

We are going to review it, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Daniel Garcia-Gil
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post 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
 
our best documentation is the source code
Isla de Margarita Venezuela.
danielgarciagil@gmail.com
http://tdolphin.blogspot.com/
https://www.dropbox.com/referrals/NTI5N ... rc=global9
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post 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

//----------------------------------------------------------------------------//
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Re: Buttonbar 2007 button with a attached Popup menu

Post by Otto »

Hello Daniel,
Would you be so kind to have another look at this problem?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org

********************************************************************
Post Reply