Focus Control 
Author Message
 Focus Control

I'm trying to create a dropdown menu sort of widget.

I've created a new Toplevel widget with no Window Manager
borders (et al) and positioned it against an already existing
window. It all works fine except that its possible to move the
first window and that makes it look odd.

Can I either
i) tie the two windows together

ii) kill the new window when the other window is manipulated.

Mike Willett

My method code looks like this :-
I've added copius amounts of grabs, focuses, waitwindow etc to get
this to work.

sub dropbox
{
    my ($cw) = shift;
    my ($entry);
    my ($x, $y);

    $cw->{drop} = $cw->Toplevel();

    $x = $cw->winfo( 'rootx' );
    $y = $cw->winfo( 'rooty' ) + $cw->winfo('height');

    $cw->{drop}->geometry( "+$x+$y" );
    $cw->{drop}->overrideredirect(1);
    $cw->{drop}->focusmodel("active");

    my $sc = $cw->{drop}->Scrollbar();
    my $lb = $cw->{drop}->Listbox(
                    -yscrollcommand => ['set', $sc],
                    -height     => 4);
    $sc->configure(-command => [ 'yview', $lb ]);

    $lb->pack(-side => 'left');
    $sc->pack(-side => 'left', -expand => 1, -fill => 'y');


    {
        $lb->insert('end', $entry);
    }

# ADD RANDOM CODE HERE
    $lb->waitWindow;
    #$cw->{drop}->grab('set');
    $lb->grab;
    $lb->forcefocus;
    $lb->raise;
    $lb->bind('<Button-1>' => sub { $cw->{drop}->destroy; } );
# STOP ADDING RANDOM CODE HERE

    $lb->bind('<Double-Button-1>' =>
                        sub {
                            my ($l) = shift;
                            my ($v) = $l->get('active');
                            $cw->{entry}->delete('0.0', 'end');
                            $cw->{entry}->insert('0.0', $v);
                            $cw->{drop}->destroy;
                        } );

Quote:
}



Fri, 10 Dec 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Controlling the focus of Window - like DialogBox.

2. focus and keyboard control

3. control C, control Z

4. Controlling Serial Control Lines?

5. Control Menu control...??

6. AS Perl, capture keypress outside window focus

7. INVITE - CODE SAMPLES FOCUS GROUP

8. perl and FOCUS database

9. CGI.pm Focus

10. Focus on that field

11. Launched Win32 apps grabbing input focus

12. getting the current focused pathname

 

 
Powered by phpBB® Forum Software