fix and improve the internal handle of focus change
enhanced textbox behavior of focus change
This commit is contained in:
@@ -95,6 +95,7 @@ namespace nana
|
||||
undo = substitute,
|
||||
|
||||
//System Code for OS
|
||||
os_tab = 0x09,
|
||||
os_shift = 0x10,
|
||||
os_ctrl = 0x11,
|
||||
os_pageup = 0x21, os_pagedown,
|
||||
|
||||
@@ -424,9 +424,18 @@ namespace nana
|
||||
|
||||
struct arg_focus : public event_arg
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::native_window_type receiver; ///< it is a native window handle, and specified which window receives focus
|
||||
bool getting; ///< the window received focus?
|
||||
/// A constant to indicate how keyboard focus emitted.
|
||||
enum class reason
|
||||
{
|
||||
general, ///< the focus is received by OS native window manager.
|
||||
tabstop, ///< the focus is received by pressing tab.
|
||||
mouse_press ///< the focus is received by pressing a mouse button.
|
||||
};
|
||||
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::native_window_type receiver; ///< it is a native window handle, and specified which window receives focus
|
||||
bool getting; ///< the window received focus?
|
||||
reason focus_reason; ///< determines how the widget receives keyboard focus, it is ignored when 'getting' is equal to false
|
||||
};
|
||||
|
||||
struct arg_keyboard : public event_arg
|
||||
|
||||
@@ -117,8 +117,9 @@ namespace nana{
|
||||
nana::paint::graphics root_graph;
|
||||
shortkey_container shortkeys;
|
||||
|
||||
struct condition_tag
|
||||
struct condition_rep
|
||||
{
|
||||
bool ignore_tab{ false }; //ignore tab when the focus is changed by pressing tab.
|
||||
core_window_t* pressed{nullptr}; //The handle to a window which has been pressed by pressing left button of mouse.
|
||||
core_window_t* pressed_by_space{ nullptr }; //The handle to a window which has been pressed by pressing spacebar.
|
||||
core_window_t* hovered{nullptr}; //the latest window that mouse moved
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace detail
|
||||
|
||||
std::vector<core_window_t*> get_children(core_window_t*) const;
|
||||
bool set_parent(core_window_t* wd, core_window_t* new_parent);
|
||||
core_window_t* set_focus(core_window_t*, bool root_has_been_focused);
|
||||
core_window_t* set_focus(core_window_t*, bool root_has_been_focused, arg_focus::reason);
|
||||
|
||||
core_window_t* capture_redirect(core_window_t*);
|
||||
void capture_ignore_children(bool ignore);
|
||||
|
||||
@@ -283,8 +283,14 @@ namespace API
|
||||
cursor window_cursor(window);
|
||||
|
||||
void activate_window(window);
|
||||
|
||||
/// Determines whether the specified window will get the keyboard focus when its root window gets native system focus.
|
||||
bool is_focus_ready(window);
|
||||
|
||||
/// Returns the current keyboard focus window.
|
||||
window focus_window();
|
||||
|
||||
/// Sets the keyboard focus for a specified window.
|
||||
void focus_window(window);
|
||||
|
||||
window capture_window();
|
||||
|
||||
@@ -229,6 +229,9 @@ namespace nana{ namespace widgets
|
||||
|
||||
/// Returns text position of each line that currently displays on screen
|
||||
const std::vector<upoint>& text_position() const;
|
||||
|
||||
void focus_behavior(text_focus_behavior);
|
||||
void select_behavior(bool move_to_end);
|
||||
public:
|
||||
void draw_corner();
|
||||
void render(bool focused);
|
||||
@@ -249,6 +252,8 @@ namespace nana{ namespace widgets
|
||||
const upoint& caret() const;
|
||||
point caret_screen_pos() const;
|
||||
bool scroll(bool upwards, bool vertical);
|
||||
|
||||
bool focus_changed(const arg_focus&);
|
||||
bool mouse_enter(bool);
|
||||
bool mouse_move(bool left_button, const point& screen_pos);
|
||||
bool mouse_pressed(const arg_mouse& arg);
|
||||
@@ -353,10 +358,13 @@ namespace nana{ namespace widgets
|
||||
|
||||
struct selection
|
||||
{
|
||||
enum mode_selection_t{mode_no_selected, mode_mouse_selected, mode_method_selected};
|
||||
enum class mode{ no_selected, mouse_selected, method_selected };
|
||||
|
||||
mode_selection_t mode_selection;
|
||||
text_focus_behavior behavior;
|
||||
bool move_to_end;
|
||||
mode mode_selection;
|
||||
bool dragged;
|
||||
bool ignore_press;
|
||||
nana::upoint a, b;
|
||||
}select_;
|
||||
|
||||
|
||||
@@ -11,6 +11,15 @@ namespace nana
|
||||
{
|
||||
namespace skeletons
|
||||
{
|
||||
enum class text_focus_behavior
|
||||
{
|
||||
none,
|
||||
select,
|
||||
select_if_tabstop,
|
||||
select_if_click,
|
||||
select_if_tabstop_or_click
|
||||
};
|
||||
|
||||
//forward declaration
|
||||
class text_editor;
|
||||
|
||||
|
||||
@@ -98,6 +98,8 @@ namespace nana
|
||||
:public widget_object<category::widget_tag, drawerbase::textbox::drawer, drawerbase::textbox::textbox_events, ::nana::widgets::skeletons::text_editor_scheme>
|
||||
{
|
||||
public:
|
||||
using text_focus_behavior = widgets::skeletons::text_focus_behavior;
|
||||
|
||||
using text_positions = std::vector<upoint>;
|
||||
/// The default constructor without creating the widget.
|
||||
textbox();
|
||||
@@ -207,6 +209,14 @@ namespace nana
|
||||
|
||||
/// Returns the height of line in pixels
|
||||
unsigned line_pixels() const;
|
||||
|
||||
/// Sets the behavior when textbox gets focus.
|
||||
void focus_behavior(text_focus_behavior);
|
||||
|
||||
/// Sets the caret move behavior when the content of textbox is selected.
|
||||
/// E.g. Whether caret moves to left of selected content or moves to left of last position when left arrow key is pressed.
|
||||
/// @param move_to_end determines whether to move caret to left of selected_content or to left of last position.
|
||||
void select_behavior(bool move_to_end);
|
||||
protected:
|
||||
//Overrides widget's virtual functions
|
||||
native_string_type _m_caption() const throw() override;
|
||||
|
||||
Reference in New Issue
Block a user