HydrogenAudio

Hosted Forums => foobar2000 => Development - (fb2k) => Topic started by: paremo on 2019-10-12 20:23:13

Title: Checking whether Layout Editing Mode is enabled to supress a custom context menu
Post by: paremo on 2019-10-12 20:23:13
I have reused/adapted CListControl demonstration code from foo_sample to add a custom context menu to my own Dialog containing only a CListControl. Unlike the demo dialogs, my dialog can also be used as a UI Element*.

During layout editing mode my dialog should provide an "*Element Name* || Replace UI Element... || Cut UI Element | Copy UI Element | Paste UI Element" context menu, as all other UI Elements do. Instead, the custom context menu is displayed. I have determined that
Code: [Select]
void OnContextMenu(CWindow wnd, CPoint point) {
  if(true)  {
     SetMsgHandled(false);
     return;
  }
  ...
}
results in the correct behaviour during layout editing mode. To make my custom context menu available the rest of the time, I would like to replace the "true" with some kind of expression that determines whether or not layout editing mode is currently enabled, but have been unable to find one.


*It is published using
Code: [Select]
class CListControlBookmarkDialog : public CDialogImpl<CListControlBookmarkDialog>, public ui_element_instance,
private IListControlBookmarkSource {
...
}
class clist_control_bookmark_impl : public ui_element_impl_withpopup<CListControlBookmarkDialog> {
};
static service_factory_t< clist_control_bookmark_impl > g_CListControlBookmarkDialog_factory;
Title: Re: Checking whether Layout Editing Mode is enabled to supress a custom context menu
Post by: marc2k3 on 2019-10-12 20:55:45
Look at foo_sample/ui_element.cpp. Look for m_callback and how it's initialised with the constructor. Once you've done that, you can use m_callback->is_edit_mode_enabled()
Title: Re: Checking whether Layout Editing Mode is enabled to supress a custom context menu
Post by: paremo on 2019-10-12 21:00:05
Thanks a lot, that's exactly what I was looking for.