| Did you know ... | Search Documentation: |
| Menu Bar |
Using a menu_bar in a frame
The example below illustrates how a menu_bar
object is used to present commands for a toolframe to the user. The demo
below uses a plain menu_bar
object. The library(toolbar) defines more high-level
infrastructure to deal with menu- and button bars.
:- set_prolog_flag(xpce_threaded, false).
:- use_module(library(pce)).
:- pce_autoload(finder, library(find_file)).
:- pce_global(@finder, new(finder)).
menu_bar_demo :-
new(F, frame('Menu Bar demo')),
send(F, append, new(D, dialog)),
send(new(V, view), below, D),
send(D, append, new(MB, menu_bar)),
send(MB, append, new(File, popup(file))),
send(MB, append, new(Help, popup(help))),
send_list(File, append,
[ menu_item(load,
message(V, load, @finder?file)),
menu_item(save,
message(V, save_buffer),
condition := V?modified == @on,
end_group := @on),
menu_item(quit,
message(F, destroy))
]),
send_list(Help, append,
[ menu_item(about,
message(@display, inform,
'By Jan Wielemaker'))
]),
send(F, open).
% Start the demo
:- initialization(menu_bar_demo).