Setting a grab on more than one widget? 
Author Message
 Setting a grab on more than one widget?

Hi,

I'm facing the following problem:
I have a parent widget, and some childrens, say A, B, C.
I want, in some circumstances, to have a grab set on A & B only (I want
the mouse & keyboard to effect A & B only).
The problem is that I can't set a grab on A, and then on B, since the
last grab cancels the former. I also can't set the grab on the parent -
since than I would have a grab set on C too.

I thought of two solutions, but I don't know if they could be
implemented, and how:

I.  Setting a grab on two widgets concurrently.
II. Creating a fictive (non-visual) parent to A & B, and setting the
grab on it. I must mention here, that the geometry won't allow me to
have A & B to be on the same form, because A is a button on the menubar,
and B is a text window, away off.
III. some other kind of disabling the widget C? (-state disabled for C
doesn't work).

Please advice,

   Rafi.



Sun, 08 Jul 2001 03:00:00 GMT  
 Setting a grab on more than one widget?

Quote:

> Hi,
> I'm facing the following problem:
> I have a parent widget, and some childrens, say A, B, C.
> I want, in some circumstances, to have a grab set on A & B only (I want
> the mouse & keyboard to effect A & B only).
> The problem is that I can't set a grab on A, and then on B, since the
> last grab cancels the former. I also can't set the grab on the parent -
> since than I would have a grab set on C too.
> I thought of two solutions, but I don't know if they could be
> implemented, and how:
> I.  Setting a grab on two widgets concurrently.
> II. Creating a fictive (non-visual) parent to A & B, and setting the
> grab on it. I must mention here, that the geometry won't allow me to
> have A & B to be on the same form, because A is a button on the menubar,
> and B is a text window, away off.
> III. some other kind of disabling the widget C? (-state disabled for C
> doesn't work).

What kind of widget is C?


Sun, 08 Jul 2001 03:00:00 GMT  
 Setting a grab on more than one widget?

Quote:

> Hi,

> I'm facing the following problem:
> I have a parent widget, and some childrens, say A, B, C.
> I want, in some circumstances, to have a grab set on A & B only (I want
> the mouse & keyboard to effect A & B only).
> The problem is that I can't set a grab on A, and then on B, since the
> last grab cancels the former. I also can't set the grab on the parent -
> since than I would have a grab set on C too.

> I thought of two solutions, but I don't know if they could be
> implemented, and how:

> I.  Setting a grab on two widgets concurrently.
> II. Creating a fictive (non-visual) parent to A & B, and setting the
> grab on it. I must mention here, that the geometry won't allow me to
> have A & B to be on the same form, because A is a button on the menubar,
> and B is a text window, away off.
> III. some other kind of disabling the widget C? (-state disabled for C
> doesn't work).

To disable bindings, you could use the bindtags method to set/delete
bindings from a widget. Here is an example on how it works:

#!/usr/local/bin/perl -w
# -*- perl -*-

use Tk;

$top = new MainWindow;

$b = $top->Button(-text => 'test button')->pack;

$top->Checkbutton(-text => 'disable/enable bindtags',
                  -command => sub {


                          $b->bindtags([]);
                      } else {


                      }
                  })->pack;

MainLoop;

__END__

If your widget is a composite widget, you probably have to disable
each composite member in this way (recurse with $widget->children).

Regards,
        Slaven

--
use Tk;$c=tkinit->Canvas->pack;$x=45;for(split/_/,'KPI1_+09IPK_K;-OA1_+K!;A__1;
Q!7G_1+QK_3CLPI90,_+K!;A_+1!KQ!.N_K+1Q!.F_1+KN.Q__1+KN._K+1Q!.F_1+KN.Q_+1Q__+1!
KQ!.N_1;Q!7G_K3,09Q_+1!K.Q_K+1Q!.F_1+KN.Q'){s/\n//g;for(split/!/){$c->create(
'line',map{$a=-43+ord;($x+($a>>3)*2,123+($a&7)*2)}split//)}$x+=12}MainLoop



Sun, 08 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Grabbing params from one CGI to another

2. Q: grab pats from one file, lookup in another

3. Grabbing Text from Text widget

4. Help grabbing a line from text widget

5. grab failed: another application has grab

6. Controlling multiple widgets with one scrollbar

7. $widget->bind returns one binding only

8. scrolling multiple widgets with one scrollbar

9. tying a widget in one canvas to the scrolling of another canvas

10. Forcing one widget to display over another

11. Can one set the referrer string using LWP module

12. Net::DNS zone transfer requires that transfer-format be set to one-answer

 

 
Powered by phpBB® Forum Software