From: Kevin Walzer on 10 Mar 2010 09:44 Is there a way to tell if a Tk command was invoked from a menu item or from a button? I'm seeing inconsistent behavior in a widget/dialog package I maintain; the dialog is drawn with different window geometry depending on whether it was called from a menu or a toolbar button. I can't quite figure out what the issue is, but as a short-term workaround I'd like to be able to set different parameters on the dialog depending on whether it was called from a menu or a button. Advice is appreciated. -- Kevin Walzer Code by Kevin http://www.codebykevin.com
From: Helmut Giese on 10 Mar 2010 10:30 Hi Kevin, >Is there a way to tell if a Tk command was invoked from a menu item or >from a button? I'm seeing inconsistent behavior in a widget/dialog >package I maintain; the dialog is drawn with different window geometry >depending on whether it was called from a menu or a toolbar button. I >can't quite figure out what the issue is, but as a short-term workaround >I'd like to be able to set different parameters on the dialog depending >on whether it was called from a menu or a button. > >Advice is appreciated. I don't know if that's possible, but a quick solution would be to add a (boolean) parameter to the event handler 'byMenu' and change the [bind] command to pass a 1 for the menu and a 0 for the button. A bit hackish, I know. HTH Helmut Giese
From: Kevin Walzer on 10 Mar 2010 10:54 On 3/10/10 10:30 AM, Helmut Giese wrote: >> >> Advice is appreciated. > I don't know if that's possible, but a quick solution would be to add > a (boolean) parameter to the event handler 'byMenu' and change the > [bind] command to pass a 1 for the menu and a 0 for the button. > > A bit hackish, I know. > HTH > Helmut Giese Is 'byMenu' a standard Tk event handler? I'm not familiar with it. -- Kevin Walzer Code by Kevin http://www.codebykevin.com
From: Helmut Giese on 10 Mar 2010 11:19 On Wed, 10 Mar 2010 10:54:11 -0500, Kevin Walzer <kw(a)codebykevin.com> wrote: >On 3/10/10 10:30 AM, Helmut Giese wrote: > >>> >>> Advice is appreciated. >> I don't know if that's possible, but a quick solution would be to add >> a (boolean) parameter to the event handler 'byMenu' and change the >> [bind] command to pass a 1 for the menu and a 0 for the button. >> >> A bit hackish, I know. >> HTH >> Helmut Giese > >Is 'byMenu' a standard Tk event handler? I'm not familiar with it. Oops, maybe I should have been more explicit. What I meant is - You have an event handler proc myAction {param1 param2} {...} - and attach it to a menu (and a button) like bind $myMnu [list myAction $val1 $val2] bind $myBtn [list myAction $val1 $val2] What I proposed was (actually rather trivial) to - change the event handler to proc myAction {param1 param2 byMenu} { if {$byMenu} { <was invoked via menu> } else { <was invoked via button> } } - and of course change the bindings to bind $myMnu [list myAction $val1 $val2 1] bind $myBtn [list myAction $val1 $val2 0] In short, it is not using a built-in feature to detect the kind of invocation (which I don't know if it exists), but rather you yourself provide the information via an additional parameter. HTH Helmut Giese
From: John Seal on 10 Mar 2010 13:58 "Kevin Walzer" <kw(a)codebykevin.com> wrote in message news:f3b02$4b97c0a3$4275d90a$7353(a)FUSE.NET... > On 3/10/10 10:30 AM, Helmut Giese wrote: >> I don't know if that's possible, but a quick solution would be to add >> a (boolean) parameter to the event handler 'byMenu' and change the >> [bind] command to pass a 1 for the menu and a 0 for the button. > Is 'byMenu' a standard Tk event handler? I'm not familiar with it. Kevin: I think he means to add a parameter named 'byMenu' to the event handler. That's the kind of mis-parsing of sentences that I find myself doing all the time! Keep up the good work.
|
Next
|
Last
Pages: 1 2 Prev: How to detect begin and end of a resize operation Next: TkPath maintainer? |