Tk-JListbox
view release on metacpan or search on metacpan
JListbox.pm view on Meta::CPAN
}
# Set the bindings for the popup menu.
sub setBindings{
my $dw = shift;
$dw->bind('<Button-3>', sub{ $dw->JraisePopup });
$dw->bind('<Button-1>', sub{ $dw->lowerPopup });
}
# Copy the selected elements to the clipboard;
sub Jcopy{
my $dw = shift;
my $popup = $dw->cget(-popupmenu);
my @selection = $dw->curselection;
if(@selection ne ""){
$dw->clipboardClear;
foreach my $index(@selection){
my $string = $dw->get($index);
# Remove any leading or trailing whitespace
$string =~ s/^\s*//;
$string =~ s/\s*$//;
$dw->clipboardAppend('--', $string);
}
}
$popup->withdraw;
$dw->grabRelease;
}
# Cut the selection and copy it to the clipboard
sub Jcut{
my $dw = shift;
my $popup = $dw->cget(-popupmenu);
my @selection = $dw->curselection;
if(@selection ne ""){
$dw->clipboardClear;
foreach my $index(@selection){
my $string = $dw->get($index);
# Remove any leading or trailing whitespace
$string =~ s/^\s*//;
$string =~ s/\s*$//;
$dw->clipboardAppend('--', $string);
# Remove the item
$dw->delete($index);
}
}
$popup->withdraw;
$dw->grabRelease;
}
JListbox.pm view on Meta::CPAN
}
# Keep current justification
$dw->justify($flag);
}
# Determine the various menu items should be 'normal' or 'disabled'
sub JsetState{
my $dw = shift;
my($selection, $clipboard);
eval { $selection = $dw->curselection };
Tk::catch{ $clipboard = $dw->SelectionGet(-selection=>'CLIPBOARD') };
my $menuref = $dw->cget(-menuitems);
# Set the default menu items to 'disabled', enabling them if appropriate
foreach my $item (@$menuref){
if($item->[0] =~ /Cut|Copy|Paste/){
$dw->{"m_$item->[0]"}->configure(-state=>'disabled');
}
}
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Only set state to 'normal' for default items if clipboard is
# not empty or selection is present.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if( (defined($selection)) && ($clipboard) && ($dw->{m_Paste})){
$dw->{m_Paste}->configure(-state=>'normal');
}
if( (defined($selection)) && ($dw->{m_Cut})){
$dw->{m_Cut}->configure(-state=>'normal');
}
if( (defined($selection)) && ($dw->{m_Copy})){
$dw->{m_Copy}->configure(-state=>'normal');
}
} #END setState()
JListbox.pm view on Meta::CPAN
character counting (depending on whether you are using a variable or
fixed width font). There have been no underlying changes in the C code
to the Tcl Listbox.
=head3 -popupmenu
If the -popupmenu option is used, a "Cut, Copy, Paste" menu will appear when
the user right-clicks anywhere on the JListbox.
The "Cut" option will remove the item from the JListbox, copy it to the
clipboard and the remaining items will shift up automatically.
The "Copy" option simply copies the selected value to the clipboard.
The "Paste" option, if selected, will bring up a Dialog window that gives the
user the option to paste (insert) above or below the selected item, as well as
on the same line, either to the left or right of the selected item.
One whitespace character is automatically separates the pasted value if the
'left' or 'right' option is chosen.
If you wish to modify the popup menu itself, you can retrieve it using the
Subwidget method with 'popupmenu' as the widget name.
set the '-expand' and '-fill' options.</P>
<P>The justification ability is provided via plain old pixel and
character counting (depending on whether you are using a variable or
fixed width font). There have been no underlying changes in the C code
to the Tcl Listbox.</P>
<P>
<H3><A NAME="popupmenu">-popupmenu</A></H3>
<P>If the -popupmenu option is used, a ``Cut, Copy, Paste'' menu will appear when
the user right-clicks anywhere on the JListbox.</P>
<P>The ``Cut'' option will remove the item from the JListbox, copy it to the
clipboard and the remaining items will shift up automatically.</P>
<P>The ``Copy'' option simply copies the selected value to the clipboard.</P>
<P>The ``Paste'' option, if selected, will bring up a Dialog window that gives the
user the option to paste (insert) above or below the selected item, as well as
on the same line, either to the left or right of the selected item.</P>
<P>One whitespace character automatically separates the pasted value from the
original value if the 'left' or 'right' option is chosen.</P>
<P>If you wish to modify the popup menu itself, you can retrieve it using the
Subwidget method with 'popupmenu' as the widget name.</P>
<P>$menu = $dw->Subwidget('popupmenu');</P>
<P>
<HR>
README.html view on Meta::CPAN
set the '-expand' and '-fill' options.</P>
<P>The justification ability is provided via plain old pixel and
character counting (depending on whether you are using a variable or
fixed width font). There have been no underlying changes in the C code
to the Tcl Listbox.</P>
<P>
<H3><A NAME="popupmenu">-popupmenu</A></H3>
<P>If the -popupmenu option is used, a ``Cut, Copy, Paste'' menu will appear when
the user right-clicks anywhere on the JListbox.</P>
<P>The ``Cut'' option will remove the item from the JListbox, copy it to the
clipboard and the remaining items will shift up automatically.</P>
<P>The ``Copy'' option simply copies the selected value to the clipboard.</P>
<P>The ``Paste'' option, if selected, will bring up a Dialog window that gives the
user the option to paste (insert) above or below the selected item, as well as
on the same line, either to the left or right of the selected item.</P>
<P>One whitespace character automatically separates the pasted value from the
original value if the 'left' or 'right' option is chosen.</P>
<P>If you wish to modify the popup menu itself, you can retrieve it using the
Subwidget method with 'popupmenu' as the widget name.</P>
<P>$menu = $dw->Subwidget('popupmenu');</P>
<P>
<HR>
( run in 1.100 second using v1.01-cache-2.11-cpan-81fc1098f69 )