add functions to menubar for auto-close when mouse leave

This commit is contained in:
Jinhao
2017-08-28 21:09:04 +08:00
parent 5c28e72320
commit 64899a3d6a
4 changed files with 61 additions and 0 deletions

View File

@@ -181,6 +181,11 @@ namespace nana
void renderer(const pat::cloneable<renderer_interface>&); ///< Sets a user-defined renderer.
const pat::cloneable<renderer_interface>& renderer() const;
/// Returns the handle of menu window
/**
* @return handle of menu window, nullptr if the menu hasn't been popped up.
*/
window handle() const;
private:
void _m_popup(window, const point& position, bool called_by_menubar);
private:

View File

@@ -64,6 +64,7 @@ namespace nana
nana::menu* push_back(const std::string&);
nana::menu* at(size_t) const;
std::size_t size() const;
bool cancel();
private:
void attached(widget_reference, graph_reference) override;
void refresh(graph_reference) override;
@@ -126,6 +127,16 @@ namespace nana
menu& push_back(const std::string&); ///< Appends a new (empty) menu.
menu& at(size_t index) const; ///< Gets the menu specified by index.
std::size_t length() const; ///< Number of menus.
/// Deselects the menu
/**
* If a menu is popped up, the menu deselects the item and close the popuped menu.
* @return true if an item is deselected, false otherwise.
*/
bool cancel();
/// Determines the mouse is hovered on the menubar or its popped menu.
bool hovered() const;
private:
::nana::event_handle evt_resized_{nullptr};
};//end class menubar