Sanko Robinson > FLTK-0.532009 > FLTK::Cookbook::MenuBar::Label


Annotate this POD


View/Report Bugs


FLTK::Cookbook::MenuBar::Label - Changing MenuItem's Labels At Runtime

Description ^

Demonstrates how to access and change menu items at run time. Click on Edit -> Change to change the contents of the Edit menu.

The Code ^

    use strict;
    use warnings;
    use FLTK;
    my $win = FLTK::Window->new(400, 400);
    my $menu = FLTK::MenuBar->new(0, 0, 400, 25);
    $menu->add("File/Quit", FLTK::CTRL() + ord 'q', sub { exit 0 });
        FLTK::CTRL() + ord 'c',
        sub {
            my $p = $menu->find('Edit/Submenu/Original Aaa');
            return if !$p;
            $p->parent->label("New Name");    # Change submenu name
            $p->label('New Aaa');             # Change item name
    $menu->add('Edit/Submenu/Original Aaa');
    exit FLTK::run();

Awknowlegements ^

Code based on the work of Greg Ercolano

Author ^

Sanko Robinson <> -

License and Legal ^

Copyright (C) 2008-2009 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or For clarification, see

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See For clarification, see

syntax highlighting: