Commit 48da04e 1 parent a0c4d92 commit 48da04e Copy full SHA for 48da04e
File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,10 @@ namespace cycfi::elements
147
147
void select_end (int pos);
148
148
void select_all ();
149
149
void select_none ();
150
+ void scroll_into_view () { _scroll_into_view = true ; }
151
+
152
+ void home ();
153
+ void end ();
150
154
151
155
virtual void draw_selection (context const & ctx);
152
156
virtual void draw_caret (context const & ctx);
@@ -199,6 +203,7 @@ namespace cycfi::elements
199
203
bool _caret_started : 1 ;
200
204
bool _read_only : 1 ;
201
205
bool _enabled : 1 ;
206
+ bool _scroll_into_view : 1 ;
202
207
state_saver_set _state_savers;
203
208
};
204
209
Original file line number Diff line number Diff line change @@ -134,6 +134,7 @@ namespace cycfi { namespace elements
134
134
, _caret_started{false }
135
135
, _read_only{false }
136
136
, _enabled{true }
137
+ , _scroll_into_view{false }
137
138
{}
138
139
139
140
struct basic_text_box ::state_saver : std::enable_shared_from_this<basic_text_box::state_saver>
@@ -169,6 +170,12 @@ namespace cycfi { namespace elements
169
170
170
171
void basic_text_box::draw (context const & ctx)
171
172
{
173
+ if (_scroll_into_view)
174
+ {
175
+ scroll_into_view (ctx, false );
176
+ _scroll_into_view = false ;
177
+ }
178
+
172
179
draw_selection (ctx);
173
180
if (_enabled)
174
181
{
@@ -882,6 +889,21 @@ namespace cycfi { namespace elements
882
889
_select_start = _select_end = -1 ;
883
890
}
884
891
892
+ void basic_text_box::home ()
893
+ {
894
+ select_start (0 );
895
+ select_end (0 );
896
+ scroll_into_view ();
897
+ }
898
+
899
+ void basic_text_box::end ()
900
+ {
901
+ auto end = get_text ().size ();
902
+ select_start (end);
903
+ select_end (end);
904
+ scroll_into_view ();
905
+ }
906
+
885
907
bool basic_text_box::word_break (int index) const
886
908
{
887
909
return get_layout ().word_break (index ) == text_layout::allow_break || line_break (index );
You can’t perform that action at this time.
0 commit comments