Commit eaa3e2d Roman Sutormin
committed
File tree 2 files changed +51
-1
lines changed
AceGWT/src/edu/ycp/cs/dh/acegwt/client/ace
AceGWTDemo/src/edu/ycp/cs/dh/acegwt/client/demo/client
2 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -226,7 +226,24 @@ public native String getText() /*-{
226
226
return editor.getSession().getValue();
227
227
}-*/ ;
228
228
229
-
229
+ /**
230
+ * Causes the editor to gain input focus.
231
+ */
232
+ public native void focus () /*-{
233
+ var editor = [email protected] ::editor;
234
+ editor.focus();
235
+ }-*/ ;
236
+
237
+ /**
238
+ * Retrieves the number of lines in the editor.
239
+ *
240
+ * @return The number of lines in the editor.
241
+ */
242
+ public native int getLineCount () /*-{
243
+ var editor = [email protected] ::editor;
244
+ return editor.session.getLength();
245
+ }-*/ ;
246
+
230
247
/**
231
248
* Set the complete text in the editor from a String.
232
249
*
Original file line number Diff line number Diff line change @@ -336,6 +336,39 @@ public void onClick(ClickEvent event) {
336
336
337
337
mainPanel .add (editor2 );
338
338
mainPanel .add (new Label ("Label below!" ));
339
+
340
+ // Demo button for get number of lines
341
+ final Button appendLineCount = new Button ("Append Line Count" );
342
+ appendLineCount .addClickHandler (new ClickHandler () {
343
+ @ Override
344
+ public void onClick (ClickEvent event ) {
345
+ final String message = editor2 .getText () + "There are "
346
+ + editor1 .getLineCount () + " lines in the main editor." ;
347
+ editor2 .setText (message );
348
+ }
349
+
350
+ });
351
+ buttonPanel2 .add (appendLineCount );
352
+
353
+ final Button flipFocus = new Button ("Focus 1st Editor" );
354
+ flipFocus .addClickHandler (new ClickHandler () {
355
+ @ Override
356
+ public void onClick (ClickEvent event ) {
357
+ editor1 .focus ();
358
+ }
359
+
360
+ });
361
+ buttonPanel2 .add (flipFocus );
362
+
363
+ final Button flipFocus2 = new Button ("Focus 2nd Editor" );
364
+ flipFocus2 .addClickHandler (new ClickHandler () {
365
+ @ Override
366
+ public void onClick (ClickEvent event ) {
367
+ editor2 .focus ();
368
+ }
369
+
370
+ });
371
+ buttonPanel2 .add (flipFocus2 );
339
372
340
373
RootPanel .get ().add (mainPanel );
341
374
}
You can’t perform that action at this time.
0 commit comments