Friday, November 24, 2017

#1 2011-09-09 07:31:24 am

houdini
Member
Registered: 2007-07-22
Posts: 11

Set insertion point for text field at end

I have a text field with some text inside. The insertion point is at the beginning. I would like to set the insertion point at the end of the text.

I have tried that without success,

Applescript:

set textcount to count of memValue
call method "setSelectedRange:" of (call method "currentEditor" of text field "screenview") with
parameter textcount

Laurent

Offline

 

#2 2011-09-09 09:07:26 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Set insertion point for text field at end

Hi,

as far as I know it's not possible to call the inherited method currentEditor of NSTextField in an AppleScript Studio environment.
Try this, please check the proper reference to the text field and the main window

Applescript:


set textField to a reference to text field "screenview" of window "main"
call method "makeFirstResponder:" of window "main" with parameters {textField}
set fieldEditor to call method "fieldEditor:forObject:" of window "main" with parameters {true, textField}
set textRange to {length of (get string value of textField), 0}
call method "setSelectedRange:" of fieldEditor with parameters {textRange}

Last edited by StefanK (2011-09-09 09:08:51 am)


regards

Stefan

Offline

 

#3 2011-09-09 02:10:41 pm

houdini
Member
Registered: 2007-07-22
Posts: 11

Re: Set insertion point for text field at end

HI,

Perfect! It works fine.

Thanks again,

Laurent

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)