ButtonFrame, A Frame with a menu button anyone?

So you have written that new, must have program. Let us see it here.
Post Reply
User avatar
BruceSteers
Posts: 443
Joined: Thursday 23rd July 2020 5:20pm

ButtonFrame, A Frame with a menu button anyone?

Post by BruceSteers » Saturday 13th March 2021 11:20am

If you ever wanted a Frame/Panel to have it's own little menu button then here you are...

It Inherits Frame.class so does everything a frame/panel does
[EDIT]
Correction it does not "Inherit" frame it is a copy of the Frame.class modified , so does everything a frame does.

Differences to a normal frame...

This frame has a RichText setting in the IDE (a normal frame you can set RichText but only with code)

You can add a menu to a little button that appears in the top right corner.
(the menu opens when button is pressed not like a Popup menu that will open no matter where you right click in the frame)
you can set the menu button picture with MenuIcon
you can enlarge the button size by enlarging the TextFont setting of the frame title.

when a menu is clicked it sets ButtonFrame.LastFrame as the frame that the menu was clicked in so you can use a single menu on multiple frames (see test app)

You can use ButtonFrame1.Contents to address the panel within the frame and not effect the frame (handy to disable the frame contents but not disable the menu button)

Note: the button is a "pseudo button" and not an actual button, Ie. it is just an image drawn on top of the frame that has no button properties the frame just reacts to a mouse click in the button area, so it will not Tab-focus or anything.
I found trying to add any kind of native control did not work due to auto-layout methods trying to place it properly or placing it before drawing and adding it own object that obscured the button., But i wanted it over the top of the frame so using Paint seemed the best way.

I made this because someone asked me to , they wanted to be able to do CRUD actions on a frame so wanted an action button.
I know nothing about CRUD so have not implemented code like that but figured a button that has a customisable menu and the menu click can tell what frame clicked then that's all you'd need for CRUD.

Maybe you can think of other reasons to have a frame with a built in menu button?


Enjoy.
Attachments
Buttonframe.zip
(122.46 KiB) Downloaded 16 times
BFrame.png
BFrame.png (188.8 KiB) Viewed 230 times
Last edited by BruceSteers on Saturday 13th March 2021 4:10pm, edited 1 time in total.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 443
Joined: Thursday 23rd July 2020 5:20pm

Re: ButtonFrame, A Frame with a menu button anyone?

Post by BruceSteers » Saturday 13th March 2021 2:16pm

This is still in development and there are still things being added/fixed. (not so much fixed as it's almost perfect ;) )

i've put it on gitlab...
https://gitlab.com/bsteers4/buttonframe

changes since the archive above...
* NEW: setting Frame foreground colour changes title text colour.
* BUG: right aligned text had top line too close to text.
Wishing well
Bruce

If at first you don't succeed , try it differently.

User avatar
BruceSteers
Posts: 443
Joined: Thursday 23rd July 2020 5:20pm

Re: ButtonFrame, A Frame with a menu button anyone?

Post by BruceSteers » Saturday 13th March 2021 6:57pm

BruceSteers wrote:
Saturday 13th March 2021 11:20am
Note: the button is a "pseudo button" and not an actual button, Ie. it is just an image drawn on top of the frame that has no button properties the frame just reacts to a mouse click in the button area, so it will not Tab-focus or anything.
I found trying to add any kind of native control did not work due to auto-layout methods trying to place it properly or placing it before drawing and adding it own object that obscured the button., But i wanted it over the top of the frame so using Paint seemed the best way.

So now it does support Tab focus :)
It creates a hidden UserControl and that actually gets the focus while the pseudo menu button displays it :)
I also added Space and Return key to open menu when focused.

I also added a MenuNoTabFocus if you do not want it to.

also made an icon for the IDE to dispay.
buttonframe.png
buttonframe.png (2.37 KiB) Viewed 211 times
https://gitlab.com/bsteers4/buttonframe
Wishing well
Bruce

If at first you don't succeed , try it differently.

Post Reply