Input fields get a default context popup menu with just
“Copy”,
“Cut”, and
“Paste” options.
Using
install_contextpopup_callback
()
on an input field replaces the default popup menu with a custom one.
copycutpastemenu.C gives
an example of adding the default options to a custom popup menu.
copycutpastemenu.C
creates a context popup menu
for an input field containing just these default options, so the
end result looks just like the default popup, but is trivially
extendible with any other options.
ifield->install_contextpopup_callback ([] (ONLY IN_THREAD, const x::w::input_field &ifield, const x::w::callback_trigger_t &trigger, const x::w::busy &mcguffin) { // ... x::w::container context_popup= ifield->create_popup_menu ([&] (const x::w::listlayoutmanager &llm) { // ... ifield->append_copy_cut_paste(IN_THREAD, ifield) ->update(IN_THREAD); }); });
copycutpastemenu.C gives an example of following the rules for managing references to the popup menu and its callbacks, and correctly creating and destroying the context popup menu after it's no longer needed.