The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::MathImage::Gtk2::Ex::Statusbar::PointerPosition -- widget pointer position message in a statusbar

SYNOPSIS

 use App::MathImage::Gtk2::Ex::Statusbar::PointerPosition;
 my $ppos = App::MathImage::Gtk2::Ex::Statusbar::PointerPosition->new
              (widget => $my_widget,
               statusbar => $my_statusbar);

WIDGET HIERARCHY

App::MathImage::Gtk2::Ex::Statusbar::PointerPosition is a Glib::Object subclass,

    Glib::Object
      Gtk2::Ex::Statusbar::Message
        App::MathImage::Gtk2::Ex::Statusbar::PointerPosition

DESCRIPTION

Experimental!

A PointerPosition object displays a message in a Gtk2::Statusbar following the mouse pointer position in a given widget.

    +--------------------------------------------+
    |                                            |
    |            *                               |
    |             \__mouse pointer               |
    |                                            |
    |                                            |
    +--------------------------------------------+
    | statusbar message about pointer position   |
    +--------------------------------------------+

The basic operation is a motion-notify-event handler on the widget and a message-string callback to get a string to show. But the advantage of PointerPosition is that it also blanks on leave and it defers updates with the Gtk2::Ex::SyncCall mechanism so as not to do more statusbar updates than can be actually displayed.

FUNCTIONS

$ppos = App::MathImage::Gtk2::Ex::Statusbar::PointerPosition->new (key=>value,...)

Create and return a new PointerPosition object. Optional key/value pairs set initial properties per Glib::Object->new.

    $ppos = App::MathImage::Gtk2::Ex::Statusbar::PointerPosition->new
               (widget => $my_widget,
                statusbar => $my_statusbar);

PROPERTIES

widget (Gtk2::Widget object, default undef)

The widget to watch for mouse motion.

In the current code this must be a windowed widget. It doesn't have to be realized or visible yet -- a statusbar message will be shown if or when that happens (and the mouse is in it).

statusbar (Gtk2::Statusbar object, default undef)

The statusbar to display a message in.

SIGNALS

message-string (parameters: widget, x, y)

Emitted as a callback to the application asking it for a message string to display for the mouse at x,y within widget.

The widget is always the PointerPosition widget parameter value, but is included as a parameter since making a message will very often want to get or check something from the widget.

    $ppos->signal_connect
        (message_string => \&my_message_string);

    sub my_message_string {
      my ($ppos, $widget, $x, $y, $userdata) = @_;
      return "mouse at X=$x Y=$y, in widget coordinates";
    }

If no message should be shown then return undef from the handler.

BUILDABLE

App::MathImage::Gtk2::Ex::Statusbar::PointerPosition can be built in a Gtk2::Builder spec the same as any other Glib::Object. The class name is "App__MathImage__Gtk2__Ex__Statusbar__PointerPosition" as usual for Perl-Gtk package name to class name conversion.

The target widget and statusbar properties can be set to objects created in the builder spec. For example

  <object class="App__MathImage__Gtk2__Ex__Statusbar__PointerPosition"
          id="pointerposition">
    <property name="widget">my_drawing</property>
    <property name="statusbar">my_statusbar</property>
  </object>

SEE ALSO

Glib::Object, Gtk2::Statusbar, Gtk2::Widget

HOME PAGE

http://user42.tuxfamily.org/math-image/index.html

LICENSE

Copyright 2010, 2011, 2012, 2013, 2014, 2019, 2020 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/.