add selection of text by using shift+mouse click
This commit is contained in:
parent
8da183cfab
commit
9fd1a594cb
@ -250,9 +250,8 @@ namespace nana{ namespace widgets
|
||||
point caret_screen_pos() const;
|
||||
bool scroll(bool upwards, bool vertical);
|
||||
bool mouse_enter(bool);
|
||||
bool mouse_down(::nana::mouse, const point& screen_pos);
|
||||
bool mouse_move(bool left_button, const point& screen_pos);
|
||||
bool mouse_up(::nana::mouse, const point& screen_pos);
|
||||
bool mouse_pressed(const arg_mouse& arg);
|
||||
|
||||
skeletons::textbase<nana::char_t>& textbase();
|
||||
const skeletons::textbase<nana::char_t>& textbase() const;
|
||||
@ -365,6 +364,7 @@ namespace nana{ namespace widgets
|
||||
{
|
||||
nana::point offset; //x stands for pixels, y for lines
|
||||
nana::upoint caret; //position of caret by text, it specifies the position of a new character
|
||||
nana::upoint shift_begin_caret;
|
||||
unsigned xpos{0}; //This data is used for move up/down
|
||||
}points_;
|
||||
};
|
||||
|
||||
@ -622,7 +622,7 @@ namespace nana
|
||||
if(drawer_->widget_ptr()->enabled())
|
||||
{
|
||||
auto * editor = drawer_->editor();
|
||||
if(false == editor->mouse_down(arg.button, arg.pos))
|
||||
if (!editor->mouse_pressed(arg))
|
||||
drawer_->open_lister_if_push_button_positioned();
|
||||
|
||||
drawer_->draw();
|
||||
@ -637,7 +637,7 @@ namespace nana
|
||||
{
|
||||
if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister())
|
||||
{
|
||||
drawer_->editor()->mouse_up(arg.button, arg.pos);
|
||||
drawer_->editor()->mouse_pressed(arg);
|
||||
drawer_->set_button_state(element_state::hovered, false);
|
||||
drawer_->draw();
|
||||
API::lazy_refresh();
|
||||
|
||||
@ -1646,30 +1646,6 @@ namespace nana{ namespace widgets
|
||||
return true;
|
||||
}
|
||||
|
||||
bool text_editor::mouse_down(::nana::mouse button, const point& scrpos)
|
||||
{
|
||||
if (!hit_text_area(scrpos))
|
||||
return false;
|
||||
|
||||
if(::nana::mouse::left_button == button)
|
||||
{
|
||||
API::capture_window(window_, true);
|
||||
text_area_.captured = true;
|
||||
|
||||
//Set caret pos by screen point and get the caret pos.
|
||||
mouse_caret(scrpos);
|
||||
if(!select(false))
|
||||
{
|
||||
select_.a = points_.caret; //Set begin caret
|
||||
set_end_caret();
|
||||
}
|
||||
select_.mode_selection = selection::mode_mouse_selected;
|
||||
}
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool text_editor::mouse_move(bool left_button, const point& scrpos)
|
||||
{
|
||||
cursor cur = cursor::iterm;
|
||||
@ -1694,7 +1670,44 @@ namespace nana{ namespace widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
bool text_editor::mouse_up(::nana::mouse button, const point& scrpos)
|
||||
bool text_editor::mouse_pressed(const arg_mouse& arg)
|
||||
{
|
||||
if (event_code::mouse_down == arg.evt_code)
|
||||
{
|
||||
if (!hit_text_area(arg.pos))
|
||||
return false;
|
||||
|
||||
if (::nana::mouse::left_button == arg.button)
|
||||
{
|
||||
API::capture_window(window_, true);
|
||||
text_area_.captured = true;
|
||||
|
||||
//Set caret pos by screen point and get the caret pos.
|
||||
mouse_caret(arg.pos);
|
||||
if (arg.shift)
|
||||
{
|
||||
if (points_.shift_begin_caret != points_.caret)
|
||||
{
|
||||
select_.a = points_.shift_begin_caret;
|
||||
select_.b = points_.caret;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!select(false))
|
||||
{
|
||||
select_.a = points_.caret; //Set begin caret
|
||||
set_end_caret();
|
||||
}
|
||||
points_.shift_begin_caret = points_.caret;
|
||||
}
|
||||
select_.mode_selection = selection::mode_mouse_selected;
|
||||
}
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
return true;
|
||||
}
|
||||
else if (event_code::mouse_up == arg.evt_code)
|
||||
{
|
||||
auto is_prev_no_selected = (select_.mode_selection == selection::mode_no_selected);
|
||||
|
||||
@ -1712,7 +1725,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
API::capture_window(window_, false);
|
||||
text_area_.captured = false;
|
||||
if (hit_text_area(scrpos) == false)
|
||||
if (hit_text_area(arg.pos) == false)
|
||||
API::window_cursor(window_, nana::cursor::arrow);
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
@ -1720,6 +1733,8 @@ namespace nana{ namespace widgets
|
||||
//Redraw if is_prev_no_selected is true
|
||||
return is_prev_no_selected;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
textbase<nana::char_t> & text_editor::textbase()
|
||||
{
|
||||
|
||||
@ -367,17 +367,13 @@ namespace nana
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool refreshed = false;
|
||||
if (pressed)
|
||||
refreshed = editor_->mouse_down(arg.button, arg.pos);
|
||||
else
|
||||
refreshed = editor_->mouse_up(arg.button, arg.pos);
|
||||
|
||||
if (refreshed)
|
||||
if (editor_->mouse_pressed(arg))
|
||||
{
|
||||
_m_draw_spins(buttons::none);
|
||||
return true;
|
||||
}
|
||||
|
||||
return refreshed;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mouse_move(bool left_button, const ::nana::point& pos)
|
||||
|
||||
@ -111,9 +111,12 @@ namespace drawerbase {
|
||||
|
||||
void drawer::mouse_down(graph_reference, const arg_mouse& arg)
|
||||
{
|
||||
if(editor_->mouse_down(arg.button, arg.pos))
|
||||
if (editor_->mouse_pressed(arg))
|
||||
{
|
||||
editor_->render(true);
|
||||
API::lazy_refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void drawer::mouse_move(graph_reference, const arg_mouse& arg)
|
||||
{
|
||||
@ -123,7 +126,7 @@ namespace drawerbase {
|
||||
|
||||
void drawer::mouse_up(graph_reference graph, const arg_mouse& arg)
|
||||
{
|
||||
if(editor_->mouse_up(arg.button, arg.pos))
|
||||
if(editor_->mouse_pressed(arg))
|
||||
API::lazy_refresh();
|
||||
}
|
||||
|
||||
|
||||
@ -161,17 +161,6 @@ namespace paint
|
||||
|
||||
image::image_impl_interface::~image_impl_interface()
|
||||
{}
|
||||
/*
|
||||
namespace detail
|
||||
{
|
||||
int toupper(int c) //deprecated
|
||||
{
|
||||
return (('a' <= c && c <= 'z') ?
|
||||
c - ('a' - 'A')
|
||||
: c);
|
||||
}
|
||||
}//end namespace detail
|
||||
//*/
|
||||
|
||||
//class image
|
||||
image::image()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user