DougHennig / Ribbon

A Microsoft Office 365-like ribbon control for VFP forms
24 stars 11 forks source link

button menu #3

Closed NigelGomm closed 2 years ago

NigelGomm commented 3 years ago

Doug, had an issue with button menus appearing in the wrong place (even the wrong monitor) depending upon a form's .showwindow setting.

So i re-worked (in my copy) sfribbonmenuform by setting .desktop = .f. .showwindow = 1 (in top-level form... more later)

then by adding an invisible button (1x1) and having .show() setfocus to it... i was able to add this.hide() to the form's .lostfocus() event and get rid of the timer.

the biggest problem was that if the ribbon is being created in a form's .init() then the 'top-level form' this menu appeared in is not the yet-to-exist-form it is supposed to be on. So.... i had to change sfribbonmenu.addbar() to store the parameters in an array and not create the sfribbonmenuform till the first call on .showmenu(). That means .addbar() doesn't return an object so i don't have submenus as yet. i'm not using submenus so haven't looked into this. Could probably add a dummy (not container) object to the array and return that.. then use that object's properties to create the submenu when it instantiates the form.

Now the menu is IN the top level it is straightforward to calculate its position; that said objtoclient() wasn't always working for me so i currently loop through parent containers summing .left and .top as i go.

it's now working for me regardless of being in _screen, top level or whatever.

Nigel

DougHennig commented 3 years ago

Can you either create a pull request or show me the code changes you made?

NigelGomm commented 3 years ago

i was going to have a crack at submenus and clean up the code a bit first... but happy to send what i have now if you would prefer.

DougHennig commented 3 years ago

I'll wait until you're done.