my $main_text_field = $top->Text(-width => 132, height => 24, -setgrid => 1, -wrap => 'word'); my $main_text_field_spelling_menu = $main_text_field->menu->Menu(-tearoff => 0); $main_text_field_spelling_menu->configure (-postcommand => [\&post_suggestion_menu, $main_text_field, $main_text_field_spelling_menu]); $main_text_field->menu->insert ('View', cascade => -label => 'Respell...', -underline => 0, -menu => $main_text_field_spelling_menu); #### sub post_suggestion_menu { my $widget = shift; my $menu = shift; my @wordpos; $menu->delete(0, 'end'); # extract word boundaries where user requested menu into @wordpos if (exists $spelling_suggestions{$word}) { $menu->add(command => -label => $_, -command => [\&replace_word, $widget, @wordpos, $_]) foreach @{$spelling_suggestions{$word}}; } else { $menu->add(command => -label => 'No suggestions.', -state => 'disabled'); } }