Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

<wiggy> in a stunning new move I actually tested this upload


devel / comp.lang.tcl / Re: tooltip with a tk_popup menu

SubjectAuthor
* tooltip with a tk_popup menuet99
`* tooltip with a tk_popup menuLuc
 `* tooltip with a tk_popup menuet99
  `* tooltip with a tk_popup menugreg
   `* tooltip with a tk_popup menugreg
    `- tooltip with a tk_popup menuet99

1
tooltip with a tk_popup menu

<ultbcp$8ep4$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=12999&group=comp.lang.tcl#12999

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: tooltip with a tk_popup menu
Date: Tue, 19 Dec 2023 16:10:00 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <ultbcp$8ep4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 20 Dec 2023 00:10:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b452a938329490864e1e4de4814aa570";
logging-data="277284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HAVNEpTAv/KKrxxXyQYtG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:eVcdfRtns+HCBF3EyLowijqzumY=
Content-Language: en-US
 by: et99 - Wed, 20 Dec 2023 00:10 UTC

Is it possible to have a tooltip with a popup menu in a toplevel window?

Here's the example in the manual which works:

package require tooltip

Demonstrate menu tooltip
.. configure -menu [menu .menu]
..menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
..menu.test add command -label Tooltip
tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"

Here's my code (which doesn't work):

package require tooltip

toplevel .mytop
console show

set ::testcb 0

# Create a menu
label .mytop.label -text "Menu"
set m [menu .mytop.menu -tearoff 0 ]
$m add command -label "testcmd" -command "puts hello-testcmd"
$m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}

pack .mytop.label

bind .mytop <1> {tk_popup .mytop.menu %X %Y}

tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"

Re: tooltip with a tk_popup menu

<20231219225801.65fdb375@lud1.home>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13001&group=comp.lang.tcl#13001

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: luc@sep.invalid (Luc)
Newsgroups: comp.lang.tcl
Subject: Re: tooltip with a tk_popup menu
Date: Tue, 19 Dec 2023 22:58:01 -0300
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <20231219225801.65fdb375@lud1.home>
References: <ultbcp$8ep4$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="20269ef817dd58ccfc488b6acfa1005b";
logging-data="278447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Uta6SdLT543edl2ySFx7XJAPUJL9PYoE="
Cancel-Lock: sha1:i2pejhg8dBl1UF5tbjv8m8Yl0jQ=
 by: Luc - Wed, 20 Dec 2023 01:58 UTC

On Tue, 19 Dec 2023 16:10:00 -0800, et99 wrote:

>Is it possible to have a tooltip with a popup menu in a toplevel window?
>
>Here's the example in the manual which works:
>
>package require tooltip
>
>Demonstrate menu tooltip
>. configure -menu [menu .menu]
>.menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
>.menu.test add command -label Tooltip
>tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
>
>
>Here's my code (which doesn't work):
>
>package require tooltip
>
>toplevel .mytop
>console show
>
>set ::testcb 0
>
># Create a menu
>label .mytop.label -text "Menu"
>set m [menu .mytop.menu -tearoff 0 ]
>$m add command -label "testcmd" -command "puts hello-testcmd"
>$m add checkbutton -label "testcb" -variable ::testcb -indicatoron
>1 -command {puts "$::testcb/checkbutton"}
>
>pack .mytop.label
>
>bind .mytop <1> {tk_popup .mytop.menu %X %Y}
>
>tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
>tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"
>
**************************

I tried it in many ways and I could only make the tooltip appear by
removing the -index options, but then it appears whenever the menu is
clicked, with no specific tooltips for each menu item like you very
probably meant.

I poked it a lot and it seems to me that tooltip is broken, or maybe
the manual is wrong.

--
Luc
>>

Re: tooltip with a tk_popup menu

<ulu4ob$fel1$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13003&group=comp.lang.tcl#13003

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: tooltip with a tk_popup menu
Date: Tue, 19 Dec 2023 23:22:51 -0800
Organization: A noiseless patient Spider
Lines: 115
Message-ID: <ulu4ob$fel1$1@dont-email.me>
References: <ultbcp$8ep4$1@dont-email.me> <20231219225801.65fdb375@lud1.home>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 20 Dec 2023 07:22:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b452a938329490864e1e4de4814aa570";
logging-data="506529"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pPGPiCnTdTs5vXsyfLlar"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:6oWXy0d9b3iCHgAVOBxkfYxwLlQ=
In-Reply-To: <20231219225801.65fdb375@lud1.home>
Content-Language: en-US
 by: et99 - Wed, 20 Dec 2023 07:22 UTC

On 12/19/2023 5:58 PM, Luc wrote:
> On Tue, 19 Dec 2023 16:10:00 -0800, et99 wrote:
>
>> Is it possible to have a tooltip with a popup menu in a toplevel window?
>>
>> Here's the example in the manual which works:
>>
>> package require tooltip
>>
>> Demonstrate menu tooltip
>> . configure -menu [menu .menu]
>> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
>> .menu.test add command -label Tooltip
>> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
>>
>>
>> Here's my code (which doesn't work):
>>
>> package require tooltip
>>
>> toplevel .mytop
>> console show
>>
>> set ::testcb 0
>>
>> # Create a menu
>> label .mytop.label -text "Menu"
>> set m [menu .mytop.menu -tearoff 0 ]
>> $m add command -label "testcmd" -command "puts hello-testcmd"
>> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron
>> 1 -command {puts "$::testcb/checkbutton"}
>>
>> pack .mytop.label
>>
>> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
>>
>> tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
>> tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"
>>
> **************************
>
> I tried it in many ways and I could only make the tooltip appear by
> removing the -index options, but then it appears whenever the menu is
> clicked, with no specific tooltips for each menu item like you very
> probably meant.
>
> I poked it a lot and it seems to me that tooltip is broken, or maybe
> the manual is wrong.
>
>

Thanks for looking into this. Yes, I want each menu item to have its own tooltip (or none).

Well, I have the tooltip code and first thing is,

for the code that works, there's a mirror copy of the .menu and .menu.test as:

w= |.#menu|
w= |.#menu.#menu#test|

And there's this:

# Menu events come from a funny path, map to the real path.
set m [string map {"#" "."} [winfo name $w]]
set cur [$w index active]

Although

% string map {"#" "."} .#menu.#menu#test
...menu..menu.test

So does Tk allow for multiple .. in a path, like with :::: in namespaces?

But my menu's don't have those built by tooltip. So, from there, when it enters the code menuMotion, it doesn't seem to be what that code wants to see.

When moving the mouse into the menu's his has the above values for w, while mine are just

w= |.mytop.menu|

This is from adding some code at the top of

proc ::tooltip::menuMotion {w} {
variable G
puts "w= |$w| "

I added 2 more menu items in the working code (the first tearoff doesn't work):

.. configure -menu [menu .menu -tearoff 1]
..menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
..menu.test add command -label Tooltip1
..menu.test add command -label Tooltip2
..menu.test add command -label Tooltip3
tooltip::tooltip .menu.test -index 0 "This is a menu tooltip0"
tooltip::tooltip .menu.test -index 1 "This is a menu tooltip1"
tooltip::tooltip .menu.test -index 2 "This is a menu tooltip2"

Here's what's he's storing, for his and mine

::::tooltip::tooltip(.menu.test,0) = This is a menu tooltip0
::::tooltip::tooltip(.menu.test,1) = This is a menu tooltip1
::::tooltip::tooltip(.menu.test,2) = This is a menu tooltip2
::::tooltip::tooltip(.mytop.menu,0) = this is a tooltip 0
::::tooltip::tooltip(.mytop.menu,testcb) = this is a tooltip 1

I'm thinking that you can't do this with another toplevel besides . or it's the configure -menu that's the problem, as I'm not using the menu bar.

Re: tooltip with a tk_popup menu

<4181ff77-da09-4f37-9981-141a1a98e54cn@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13006&group=comp.lang.tcl#13006

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a0c:c58d:0:b0:67a:94a9:4747 with SMTP id a13-20020a0cc58d000000b0067a94a94747mr159285qvj.9.1703103478737;
Wed, 20 Dec 2023 12:17:58 -0800 (PST)
X-Received: by 2002:a05:622a:1705:b0:427:922f:429f with SMTP id
h5-20020a05622a170500b00427922f429fmr64800qtk.1.1703103478515; Wed, 20 Dec
2023 12:17:58 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.chmurka.net!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 20 Dec 2023 12:17:58 -0800 (PST)
In-Reply-To: <ulu4ob$fel1$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.121; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.121
References: <ultbcp$8ep4$1@dont-email.me> <20231219225801.65fdb375@lud1.home> <ulu4ob$fel1$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4181ff77-da09-4f37-9981-141a1a98e54cn@googlegroups.com>
Subject: Re: tooltip with a tk_popup menu
From: gregor.ebbing@googlemail.com (greg)
Injection-Date: Wed, 20 Dec 2023 20:17:58 +0000
Content-Type: text/plain; charset="UTF-8"
 by: greg - Wed, 20 Dec 2023 20:17 UTC

et99 schrieb am Mittwoch, 20. Dezember 2023 um 08:22:57 UTC+1:
> On 12/19/2023 5:58 PM, Luc wrote:
> > On Tue, 19 Dec 2023 16:10:00 -0800, et99 wrote:
> >
> >> Is it possible to have a tooltip with a popup menu in a toplevel window?
> >>
> >> Here's the example in the manual which works:
> >>
> >> package require tooltip
> >>
> >> Demonstrate menu tooltip
> >> . configure -menu [menu .menu]
> >> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
> >> .menu.test add command -label Tooltip
> >> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
> >>
> >>
> >> Here's my code (which doesn't work):
> >>
> >> package require tooltip
> >>
> >> toplevel .mytop
> >> console show
> >>
> >> set ::testcb 0
> >>
> >> # Create a menu
> >> label .mytop.label -text "Menu"
> >> set m [menu .mytop.menu -tearoff 0 ]
> >> $m add command -label "testcmd" -command "puts hello-testcmd"
> >> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron
> >> 1 -command {puts "$::testcb/checkbutton"}
> >>
> >> pack .mytop.label
> >>
> >> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
> >>
> >> tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
> >> tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"
> >>
> > **************************
> >
> > I tried it in many ways and I could only make the tooltip appear by
> > removing the -index options, but then it appears whenever the menu is
> > clicked, with no specific tooltips for each menu item like you very
> > probably meant.
> >
> > I poked it a lot and it seems to me that tooltip is broken, or maybe
> > the manual is wrong.
> >
> >
> Thanks for looking into this. Yes, I want each menu item to have its own tooltip (or none).
>
> Well, I have the tooltip code and first thing is,
>
> for the code that works, there's a mirror copy of the .menu and .menu.test as:
>
> w= |.#menu|
> w= |.#menu.#menu#test|
>
> And there's this:
>
> # Menu events come from a funny path, map to the real path.
> set m [string map {"#" "."} [winfo name $w]]
> set cur [$w index active]
>
> Although
>
> % string map {"#" "."} .#menu.#menu#test
> ..menu..menu.test
>
> So does Tk allow for multiple .. in a path, like with :::: in namespaces?
>
>
> But my menu's don't have those built by tooltip. So, from there, when it enters the code menuMotion, it doesn't seem to be what that code wants to see.
>
> When moving the mouse into the menu's his has the above values for w, while mine are just
>
> w= |.mytop.menu|
>
> This is from adding some code at the top of
>
> proc ::tooltip::menuMotion {w} {
> variable G
> puts "w= |$w| "
>
>
>
> I added 2 more menu items in the working code (the first tearoff doesn't work):
>
> . configure -menu [menu .menu -tearoff 1]
> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
> .menu.test add command -label Tooltip1
> .menu.test add command -label Tooltip2
> .menu.test add command -label Tooltip3
> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip0"
> tooltip::tooltip .menu.test -index 1 "This is a menu tooltip1"
> tooltip::tooltip .menu.test -index 2 "This is a menu tooltip2"
>
> Here's what's he's storing, for his and mine
>
> ::::tooltip::tooltip(.menu.test,0) = This is a menu tooltip0
> ::::tooltip::tooltip(.menu.test,1) = This is a menu tooltip1
> ::::tooltip::tooltip(.menu.test,2) = This is a menu tooltip2
> ::::tooltip::tooltip(.mytop.menu,0) = this is a tooltip 0
> ::::tooltip::tooltip(.mytop.menu,testcb) = this is a tooltip 1
>
> I'm thinking that you can't do this with another toplevel besides . or it's the configure -menu that's the problem, as I'm not using the menu bar.

Hello,
with baltip
https://github.com/aplsimple/baltip
https://wiki.tcl-lang.org/page/baltip%2C+balloon+tip

#package require tooltip
package require baltip
toplevel .mytop
console show

set ::testcb 0

# Create a menu
label .mytop.label -text "Menu"
set m [menu .mytop.menu -tearoff 0 ]
$m add command -label "testcmd" -command "puts hello-testcmd"
$m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}

pack .mytop.label

bind .mytop <1> {tk_popup .mytop.menu %X %Y}

::baltip::tip $m "this is tooltip 0" -index 0
::baltip::tip $m "this is tooltip 1" -index 1

Re: tooltip with a tk_popup menu

<3f0670cf-9023-4b74-baec-263ab670af78n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13007&group=comp.lang.tcl#13007

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:622a:1883:b0:425:7083:1460 with SMTP id v3-20020a05622a188300b0042570831460mr797859qtc.13.1703104212673;
Wed, 20 Dec 2023 12:30:12 -0800 (PST)
X-Received: by 2002:ad4:4350:0:b0:67f:80c1:6e46 with SMTP id
q16-20020ad44350000000b0067f80c16e46mr8286qvs.1.1703104212334; Wed, 20 Dec
2023 12:30:12 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Wed, 20 Dec 2023 12:30:12 -0800 (PST)
In-Reply-To: <4181ff77-da09-4f37-9981-141a1a98e54cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.121; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.121
References: <ultbcp$8ep4$1@dont-email.me> <20231219225801.65fdb375@lud1.home>
<ulu4ob$fel1$1@dont-email.me> <4181ff77-da09-4f37-9981-141a1a98e54cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3f0670cf-9023-4b74-baec-263ab670af78n@googlegroups.com>
Subject: Re: tooltip with a tk_popup menu
From: gregor.ebbing@googlemail.com (greg)
Injection-Date: Wed, 20 Dec 2023 20:30:12 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 6769
 by: greg - Wed, 20 Dec 2023 20:30 UTC

greg schrieb am Mittwoch, 20. Dezember 2023 um 21:18:01 UTC+1:
> et99 schrieb am Mittwoch, 20. Dezember 2023 um 08:22:57 UTC+1:
> > On 12/19/2023 5:58 PM, Luc wrote:
> > > On Tue, 19 Dec 2023 16:10:00 -0800, et99 wrote:
> > >
> > >> Is it possible to have a tooltip with a popup menu in a toplevel window?
> > >>
> > >> Here's the example in the manual which works:
> > >>
> > >> package require tooltip
> > >>
> > >> Demonstrate menu tooltip
> > >> . configure -menu [menu .menu]
> > >> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
> > >> .menu.test add command -label Tooltip
> > >> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
> > >>
> > >>
> > >> Here's my code (which doesn't work):
> > >>
> > >> package require tooltip
> > >>
> > >> toplevel .mytop
> > >> console show
> > >>
> > >> set ::testcb 0
> > >>
> > >> # Create a menu
> > >> label .mytop.label -text "Menu"
> > >> set m [menu .mytop.menu -tearoff 0 ]
> > >> $m add command -label "testcmd" -command "puts hello-testcmd"
> > >> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron
> > >> 1 -command {puts "$::testcb/checkbutton"}
> > >>
> > >> pack .mytop.label
> > >>
> > >> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
> > >>
> > >> tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
> > >> tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"
> > >>
> > > **************************
> > >
> > > I tried it in many ways and I could only make the tooltip appear by
> > > removing the -index options, but then it appears whenever the menu is
> > > clicked, with no specific tooltips for each menu item like you very
> > > probably meant.
> > >
> > > I poked it a lot and it seems to me that tooltip is broken, or maybe
> > > the manual is wrong.
> > >
> > >
> > Thanks for looking into this. Yes, I want each menu item to have its own tooltip (or none).
> >
> > Well, I have the tooltip code and first thing is,
> >
> > for the code that works, there's a mirror copy of the .menu and .menu.test as:
> >
> > w= |.#menu|
> > w= |.#menu.#menu#test|
> >
> > And there's this:
> >
> > # Menu events come from a funny path, map to the real path.
> > set m [string map {"#" "."} [winfo name $w]]
> > set cur [$w index active]
> >
> > Although
> >
> > % string map {"#" "."} .#menu.#menu#test
> > ..menu..menu.test
> >
> > So does Tk allow for multiple .. in a path, like with :::: in namespaces?
> >
> >
> > But my menu's don't have those built by tooltip. So, from there, when it enters the code menuMotion, it doesn't seem to be what that code wants to see.
> >
> > When moving the mouse into the menu's his has the above values for w, while mine are just
> >
> > w= |.mytop.menu|
> >
> > This is from adding some code at the top of
> >
> > proc ::tooltip::menuMotion {w} {
> > variable G
> > puts "w= |$w| "
> >
> >
> >
> > I added 2 more menu items in the working code (the first tearoff doesn't work):
> >
> > . configure -menu [menu .menu -tearoff 1]
> > .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
> > .menu.test add command -label Tooltip1
> > .menu.test add command -label Tooltip2
> > .menu.test add command -label Tooltip3
> > tooltip::tooltip .menu.test -index 0 "This is a menu tooltip0"
> > tooltip::tooltip .menu.test -index 1 "This is a menu tooltip1"
> > tooltip::tooltip .menu.test -index 2 "This is a menu tooltip2"
> >
> > Here's what's he's storing, for his and mine
> >
> > ::::tooltip::tooltip(.menu.test,0) = This is a menu tooltip0
> > ::::tooltip::tooltip(.menu.test,1) = This is a menu tooltip1
> > ::::tooltip::tooltip(.menu.test,2) = This is a menu tooltip2
> > ::::tooltip::tooltip(.mytop.menu,0) = this is a tooltip 0
> > ::::tooltip::tooltip(.mytop.menu,testcb) = this is a tooltip 1
> >
> > I'm thinking that you can't do this with another toplevel besides . or it's the configure -menu that's the problem, as I'm not using the menu bar.
> Hello,
> with baltip
> https://github.com/aplsimple/baltip
> https://wiki.tcl-lang.org/page/baltip%2C+balloon+tip
>
> #package require tooltip
> package require baltip
> toplevel .mytop
> console show
>
> set ::testcb 0
>
> # Create a menu
> label .mytop.label -text "Menu"
> set m [menu .mytop.menu -tearoff 0 ]
> $m add command -label "testcmd" -command "puts hello-testcmd"
> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}
>
> pack .mytop.label
>
> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
> ::baltip::tip $m "this is tooltip 0" -index 0
> ::baltip::tip $m "this is tooltip 1" -index 1

a small change that is not necessary:
menu post instead of tk_popup

########
package require Tk
#package require tooltip
package require baltip
toplevel .mytop
#console show

set ::testcb 0

# Create a menu
label .mytop.label -text "Menu"
set m [menu .mytop.menu -tearoff 0 ]
$m add command -label "testcmd" -command "puts hello-testcmd"
$m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}

pack .mytop.label

#menu post instead of tk_popup
#bind .mytop <1> {tk_popup .mytop.menu %X %Y}
bind .mytop <1> {.mytop.menu post %X %Y}

::baltip::tip $m "this is tooltip 0" -index 0
::baltip::tip $m "this is tooltip 1" -index 1

Re: tooltip with a tk_popup menu

<um02hq$p3v8$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13008&group=comp.lang.tcl#13008

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: tooltip with a tk_popup menu
Date: Wed, 20 Dec 2023 16:57:30 -0800
Organization: A noiseless patient Spider
Lines: 199
Message-ID: <um02hq$p3v8$1@dont-email.me>
References: <ultbcp$8ep4$1@dont-email.me> <20231219225801.65fdb375@lud1.home>
<ulu4ob$fel1$1@dont-email.me>
<4181ff77-da09-4f37-9981-141a1a98e54cn@googlegroups.com>
<3f0670cf-9023-4b74-baec-263ab670af78n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Dec 2023 00:57:30 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fa683992c94a7d29b31c37e56ac3be04";
logging-data="823272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1800zaLMlHw57Prnr7y4UAG"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:SkqFXbauh19P4KoxBUYgY1byAO8=
Content-Language: en-US
In-Reply-To: <3f0670cf-9023-4b74-baec-263ab670af78n@googlegroups.com>
 by: et99 - Thu, 21 Dec 2023 00:57 UTC

On 12/20/2023 12:30 PM, greg wrote:
> greg schrieb am Mittwoch, 20. Dezember 2023 um 21:18:01 UTC+1:
>> et99 schrieb am Mittwoch, 20. Dezember 2023 um 08:22:57 UTC+1:
>>> On 12/19/2023 5:58 PM, Luc wrote:
>>>> On Tue, 19 Dec 2023 16:10:00 -0800, et99 wrote:
>>>>
>>>>> Is it possible to have a tooltip with a popup menu in a toplevel window?
>>>>>
>>>>> Here's the example in the manual which works:
>>>>>
>>>>> package require tooltip
>>>>>
>>>>> Demonstrate menu tooltip
>>>>> . configure -menu [menu .menu]
>>>>> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
>>>>> .menu.test add command -label Tooltip
>>>>> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
>>>>>
>>>>>
>>>>> Here's my code (which doesn't work):
>>>>>
>>>>> package require tooltip
>>>>>
>>>>> toplevel .mytop
>>>>> console show
>>>>>
>>>>> set ::testcb 0
>>>>>
>>>>> # Create a menu
>>>>> label .mytop.label -text "Menu"
>>>>> set m [menu .mytop.menu -tearoff 0 ]
>>>>> $m add command -label "testcmd" -command "puts hello-testcmd"
>>>>> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron
>>>>> 1 -command {puts "$::testcb/checkbutton"}
>>>>>
>>>>> pack .mytop.label
>>>>>
>>>>> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
>>>>>
>>>>> tooltip::tooltip .mytop.menu -index 0 "this is a tooltip 0"
>>>>> tooltip::tooltip .mytop.menu -index "testcb" "this is a tooltip 1"
>>>>>
>>>> **************************
>>>>
>>>> I tried it in many ways and I could only make the tooltip appear by
>>>> removing the -index options, but then it appears whenever the menu is
>>>> clicked, with no specific tooltips for each menu item like you very
>>>> probably meant.
>>>>
>>>> I poked it a lot and it seems to me that tooltip is broken, or maybe
>>>> the manual is wrong.
>>>>
>>>>
>>> Thanks for looking into this. Yes, I want each menu item to have its own tooltip (or none).
>>>
>>> Well, I have the tooltip code and first thing is,
>>>
>>> for the code that works, there's a mirror copy of the .menu and .menu.test as:
>>>
>>> w= |.#menu|
>>> w= |.#menu.#menu#test|
>>>
>>> And there's this:
>>>
>>> # Menu events come from a funny path, map to the real path.
>>> set m [string map {"#" "."} [winfo name $w]]
>>> set cur [$w index active]
>>>
>>> Although
>>>
>>> % string map {"#" "."} .#menu.#menu#test
>>> ..menu..menu.test
>>>
>>> So does Tk allow for multiple .. in a path, like with :::: in namespaces?
>>>
>>>
>>> But my menu's don't have those built by tooltip. So, from there, when it enters the code menuMotion, it doesn't seem to be what that code wants to see.
>>>
>>> When moving the mouse into the menu's his has the above values for w, while mine are just
>>>
>>> w= |.mytop.menu|
>>>
>>> This is from adding some code at the top of
>>>
>>> proc ::tooltip::menuMotion {w} {
>>> variable G
>>> puts "w= |$w| "
>>>
>>>
>>>
>>> I added 2 more menu items in the working code (the first tearoff doesn't work):
>>>
>>> . configure -menu [menu .menu -tearoff 1]
>>> .menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
>>> .menu.test add command -label Tooltip1
>>> .menu.test add command -label Tooltip2
>>> .menu.test add command -label Tooltip3
>>> tooltip::tooltip .menu.test -index 0 "This is a menu tooltip0"
>>> tooltip::tooltip .menu.test -index 1 "This is a menu tooltip1"
>>> tooltip::tooltip .menu.test -index 2 "This is a menu tooltip2"
>>>
>>> Here's what's he's storing, for his and mine
>>>
>>> ::::tooltip::tooltip(.menu.test,0) = This is a menu tooltip0
>>> ::::tooltip::tooltip(.menu.test,1) = This is a menu tooltip1
>>> ::::tooltip::tooltip(.menu.test,2) = This is a menu tooltip2
>>> ::::tooltip::tooltip(.mytop.menu,0) = this is a tooltip 0
>>> ::::tooltip::tooltip(.mytop.menu,testcb) = this is a tooltip 1
>>>
>>> I'm thinking that you can't do this with another toplevel besides . or it's the configure -menu that's the problem, as I'm not using the menu bar.
>> Hello,
>> with baltip
>> https://github.com/aplsimple/baltip
>> https://wiki.tcl-lang.org/page/baltip%2C+balloon+tip
>>
>> #package require tooltip
>> package require baltip
>> toplevel .mytop
>> console show
>>
>> set ::testcb 0
>>
>> # Create a menu
>> label .mytop.label -text "Menu"
>> set m [menu .mytop.menu -tearoff 0 ]
>> $m add command -label "testcmd" -command "puts hello-testcmd"
>> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}
>>
>> pack .mytop.label
>>
>> bind .mytop <1> {tk_popup .mytop.menu %X %Y}
>> ::baltip::tip $m "this is tooltip 0" -index 0
>> ::baltip::tip $m "this is tooltip 1" -index 1
>
> a small change that is not necessary:
> menu post instead of tk_popup
>
> ########
> package require Tk
> #package require tooltip
> package require baltip
> toplevel .mytop
> #console show
>
> set ::testcb 0
>
> # Create a menu
> label .mytop.label -text "Menu"
> set m [menu .mytop.menu -tearoff 0 ]
> $m add command -label "testcmd" -command "puts hello-testcmd"
> $m add checkbutton -label "testcb" -variable ::testcb -indicatoron 1 -command {puts "$::testcb/checkbutton"}
>
> pack .mytop.label
>
> #menu post instead of tk_popup
> #bind .mytop <1> {tk_popup .mytop.menu %X %Y}
> bind .mytop <1> {.mytop.menu post %X %Y}
>
> ::baltip::tip $m "this is tooltip 0" -index 0
> ::baltip::tip $m "this is tooltip 1" -index 1

Wow, interesting package. If I had read your post earlier, I would have been quite tempted to use this.

However, I was successful at finding the problem in the existing tooltip package. Also, when I used the latest baltip version off github (1.6.0) it displays the tips underneath the menu items - although when using magicsplat's distro, with baltip 1.3.7 it doesn't do that. I tried several 8.6's and even 9.0b1 and the problem follows baltip 1.6.0.

Funny though, baltip also has the same problem that my fix has which is the tip doesn't go away when you move off the menu item (unless you move to another item that also has or hasn't a tip). I was debating whether to track that down in tooltip or not. Probably not.

And I also see that it creates menus with # in the name. This is something which I wasn't able to find the code that actually does that. However, these are only for menubar menus and I'm beginning to wonder if it's in Tk that it's actually done.

---------------------

Anyway, my fix to tooltip for anyone who might be curious, is that when they didn't find the menu item they were looking for in the tooltip array after the mapping of # for dots, I just use the one that was saved in the tooltip array, in menuMotion:

proc ::tooltip::menuMotion {w} {
variable G
<snip>
set m [string map {"#" "."} [winfo name $w]] ;# here's that # magic mapping
<snip>

catch {wm withdraw $G(TOPLEVEL)}

if { ! [info exists tooltip($m,$cur)]} { ;# fix here when not finding this
if { [info exists tooltip($w,$cur)] } {
set m $w ;# just use the one before the # mapping
}

}

I do like how baltip allows for much more customization of the tips. Many programs I use are almost entirely documented using tooltips, and many allow for multiple fonts and styles, bold etc. in the tips.


Click here to read the complete article
1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor