NAME
App::MathImage::Perl::WidgetBits -- miscellaneous Tk widget helpers
SYNOPSIS
use App::MathImage::Perl::WidgetBits 'with_underline';
FUNCTIONS
($str, -underline => $pos) = with_underline($str)
-
This function is designed for use on a
-label
or-text
argument to aTk::Menu
or similar.$menu->command (-label => with_underline("_File"), -command => ...)
If
$str
has an underscore like "Save _As" then return 3 values"Save As", -underline => 5
so the underscore becomes a-underline
parameter, ie.-label => "Save As", -underline => 5,
If
$str
doesn't have an underscore then return$str
unchanged.A literal underscore can be included by doubling it, for example
"Literal__Underscore" # gives "Literal_Underscore"
Extracting an underline position from a string like this is easier than counting characters manually to make a
-underline
argument. It's also easier if translating labels into other languages (Locale::TextDomain
or similar) since the underline position will be different in a different language or there might be no underline at all.
EXPORTS
Nothing is exported by default but all the functions can be imported in usual Exporter style
use App::MathImage::Perl::WidgetBits 'with_underline';
A with_underline()
import is recommended for source readability, though it works perfectly well with a full module name.
SEE ALSO
HOME PAGE
http://user42.tuxfamily.org/math-image/index.html
LICENSE
Copyright 2011, 2012, 2013, 2014, 2019 Kevin Ryde
Math-Image is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-Image is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-Image. If not, see http://www.gnu.org/licenses/.