Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

add image/button to menu?

73 views
Skip to first unread message

Juge

unread,
Jul 1, 2015, 2:28:33 AM7/1/15
to
I have a kind of browser that goes through folders in a database.
I wanted to add a bookmark/favourite function and chose to implement
a menubutton. Sofar so good, I guess I can add bookmarks to the menu
quite easily, but I am struggling with removing them.

I was thinking about adding the items with small "X" button. If I choose the "X"-button the menu item would be removed. Alternatively I could bind a del-key to each menuitem, but I am not sure how to accomplish that on the fly?

Harald Oehlmann

unread,
Jul 1, 2015, 3:42:57 AM7/1/15
to
Dear Juge,

I don't get it totally:

- menubutton with a list of entries.
[B]-+-EA
+-EB
+-EC

You want to have the possibility that the user removes the entries.

There is no way to put a delete button within the menu entries AFAIK.

I would:
add a submenu "Delete" with the whole item list again.
[B]-+-EA
+-EB
+-EC
+-Delete-+-EA
+-EB
+-EC

If you really want to have buttons, you must build the popup-widget on your own.
So use a normal toolbutton and show a window when pressed which contains a set of buttons for each item, one to open the bookmark, one to delete it.

-Harald

Juge

unread,
Jul 2, 2015, 4:20:49 AM7/2/15
to
Hi what about binding the Delete Key? Going over an entry and pressing Del to remove it? I just do not know how to make a bind to a popup menu?

Uwe Klein

unread,
Jul 5, 2015, 4:50:04 AM7/5/15
to
What about also binding "left click" ( where right click" activates the
entry ) and create an "Edit" widget on demand
that allows introspect, change, delete, ...

uwe

Juge

unread,
Jul 5, 2015, 1:57:45 PM7/5/15
to
Also a good idea, however I do not have an idea how to bind right click to a menuobject? What to use for widget or a bodytag?

Rich

unread,
Jul 5, 2015, 3:10:31 PM7/5/15
to
Juge <jyrki.m...@gmail.com> wrote:
> Also a good idea, however I do not have an idea how to bind right
> click to a menuobject? What to use for widget or a bodytag?

This is Tcl/Tk, read the man pages and start experimenting:

#!/usr/bin/wish

menubutton .mb -text "Push Me"
pack .mb

menu .mb.menu
.mb.menu add command -label A -command [list puts menu-item-a]
.mb.menu add command -label B -command [list puts menu-item-b]

.mb configure -menu .mb.menu

bind .mb.menu <Button-3> {RC %W %y}

proc RC {w y} {
set idx [$w index @$y]
# if the menu has a tearoff entry, do nothing with it here
if {[$w cget -tearoff] && ($idx == 0)} {return}
puts "Menu entry with -label [$w entrycget $idx -label] right-clicked"
return -code break
}

What I've not bothered to dig out yet is how to turn off the menu
entry's -command option firing as well after the right-click binding.

Mike Griffiths

unread,
Jul 5, 2015, 4:42:35 PM7/5/15
to
That's going to be pretty platform-specific; on Windows, at least, you can't bind to [menu]s because they're native Windows menus, and Tk gives you very little control over them beyond setting -command and other options.

Rich

unread,
Jul 5, 2015, 9:19:00 PM7/5/15
to
That would quite ruin the party very badly then.

> and Tk gives you very little control over them beyond setting
> -command and other options.

Likely because the windows API gives Tk little leeway to play.
0 new messages