Merge branch 'os12-double-click' into hotfix-1.5.3
This commit is contained in:
		
						commit
						8fa2cf13f5
					
				@ -211,6 +211,7 @@ namespace nana{	namespace widgets
 | 
				
			|||||||
			bool mouse_enter(bool entering);
 | 
								bool mouse_enter(bool entering);
 | 
				
			||||||
			bool mouse_move(bool left_button, const point& screen_pos);
 | 
								bool mouse_move(bool left_button, const point& screen_pos);
 | 
				
			||||||
			void mouse_pressed(const arg_mouse& arg);
 | 
								void mouse_pressed(const arg_mouse& arg);
 | 
				
			||||||
 | 
					                        bool select_word(const arg_mouse& arg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			skeletons::textbase<char_type>& textbase();
 | 
								skeletons::textbase<char_type>& textbase();
 | 
				
			||||||
			const skeletons::textbase<char_type>& textbase() const;
 | 
								const skeletons::textbase<char_type>& textbase() const;
 | 
				
			||||||
 | 
				
			|||||||
@ -80,6 +80,7 @@ namespace nana
 | 
				
			|||||||
				void mouse_up(graph_reference, const arg_mouse&)	override;
 | 
									void mouse_up(graph_reference, const arg_mouse&)	override;
 | 
				
			||||||
				void mouse_enter(graph_reference, const arg_mouse&)	override;
 | 
									void mouse_enter(graph_reference, const arg_mouse&)	override;
 | 
				
			||||||
				void mouse_leave(graph_reference, const arg_mouse&)	override;
 | 
									void mouse_leave(graph_reference, const arg_mouse&)	override;
 | 
				
			||||||
 | 
									void dbl_click(graph_reference, const arg_mouse&)	override;
 | 
				
			||||||
				void key_press(graph_reference, const arg_keyboard&)override;
 | 
									void key_press(graph_reference, const arg_keyboard&)override;
 | 
				
			||||||
				void key_char(graph_reference, const arg_keyboard&)	override;
 | 
									void key_char(graph_reference, const arg_keyboard&)	override;
 | 
				
			||||||
				void mouse_wheel(graph_reference, const arg_wheel&)	override;
 | 
									void mouse_wheel(graph_reference, const arg_wheel&)	override;
 | 
				
			||||||
 | 
				
			|||||||
@ -1580,6 +1580,43 @@ namespace nana{	namespace widgets
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							bool text_editor::select_word(const arg_mouse& arg)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if(!attributes_.enable_caret)
 | 
				
			||||||
 | 
									return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								auto is_whitespace = [](wchar_t c) {
 | 
				
			||||||
 | 
									switch (c) {
 | 
				
			||||||
 | 
									case L' ':
 | 
				
			||||||
 | 
									case L'\t':
 | 
				
			||||||
 | 
									case L'\n':
 | 
				
			||||||
 | 
									case L'\r':
 | 
				
			||||||
 | 
									    return true;
 | 
				
			||||||
 | 
									default:
 | 
				
			||||||
 | 
									    return false;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Set caret pos by screen point and get the caret pos.
 | 
				
			||||||
 | 
								mouse_caret(arg.pos, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Set the initial selection: it is an empty range.
 | 
				
			||||||
 | 
								select_.a = select_.b = points_.caret;
 | 
				
			||||||
 | 
								const auto& line = impl_->textbase.getline(select_.b.y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Expand the selection forward to the word's end.
 | 
				
			||||||
 | 
								while (select_.b.x < line.size() && !is_whitespace(line[select_.b.x]))
 | 
				
			||||||
 | 
									++select_.b.x;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								// Expand the selection backward to the word's start.
 | 
				
			||||||
 | 
								while (select_.a.x > 0 && !is_whitespace(line[select_.a.x - 1]))
 | 
				
			||||||
 | 
									--select_.a.x;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								select_.mode_selection = selection::mode::method_selected;
 | 
				
			||||||
 | 
								impl_->try_refresh = sync_graph::refresh;
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		textbase<text_editor::char_type> & text_editor::textbase()
 | 
							textbase<text_editor::char_type> & text_editor::textbase()
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			return impl_->textbase;
 | 
								return impl_->textbase;
 | 
				
			||||||
 | 
				
			|||||||
@ -143,6 +143,12 @@ namespace drawerbase {
 | 
				
			|||||||
				API::dev::lazy_refresh();
 | 
									API::dev::lazy_refresh();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							void drawer::dbl_click(graph_reference, const arg_mouse& arg)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if(editor_->select_word(arg))
 | 
				
			||||||
 | 
									API::dev::lazy_refresh();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void drawer::key_press(graph_reference, const arg_keyboard& arg)
 | 
							void drawer::key_press(graph_reference, const arg_keyboard& arg)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			editor_->respond_key(arg);
 | 
								editor_->respond_key(arg);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user