Selecting text from locked field

Need help with a script? This is the place to discuss how to get your code running!

Selecting text from locked field

Postby sandrobilbeisi » Fri Dec 29, 2017 12:34 pm

maybe this should be a feature request ---

text fields that have their lockText property set to true not only do not allow editing,
but quite inconveniently also prohibit selecting the text -


is there a workaround that allows text selection from a locked field ?
sandrobilbeisi
 
Posts: 35
Joined: Mon Dec 04, 2017 1:11 am

Re: Selecting text from locked field

Postby JoeKoomen2011 » Fri Dec 29, 2017 12:58 pm

You can set the "cantmodify" property of the field to true. Then you can copy text out of the field, but you can only modify it by setting the property to false or setting the contents by script.

That's how the fields in the help project work.
Joe Koomen
>> Random! ...Damn near killed 'em! <<
User avatar
JoeKoomen2011
 
Posts: 470
Joined: Thu Mar 12, 2009 1:38 pm

Re: Selecting text from locked field

Postby sandrobilbeisi » Sat Dec 30, 2017 2:25 am

yes, thanks

but the mouseUp message is not sent

messages that do work without locktext :
  • clickFieldObject
  • clickInField
  • doubleClickField
  • DoubleClickFieldObject

messages that do NOT work without locktext :
  • mouseDown
  • mouseUp

* clickFieldObject only works for PICT objects if the locktext is set to true, otherwise it always works with text HLinks
sandrobilbeisi
 
Posts: 35
Joined: Mon Dec 04, 2017 1:11 am

Re: Selecting text from locked field

Postby JoeKoomen2011 » Sat Dec 30, 2017 4:15 am

It isn't logical to want text that's clickable and selectable. I would suggest that you use a modifier key.

on mouseDown
if optionKey is down then set the cantmodify of this field to false
....
Joe Koomen
>> Random! ...Damn near killed 'em! <<
User avatar
JoeKoomen2011
 
Posts: 470
Joined: Thu Mar 12, 2009 1:38 pm

Re: Selecting text from locked field

Postby sandrobilbeisi » Sat Dec 30, 2017 4:44 am

well , the SuperCard (and HyperCard) paradigm was born a few years before the web and even influenced it ..

in a web view , you can select linked text provided that you extend the cursor mousedown sweep around the chunk
sandrobilbeisi
 
Posts: 35
Joined: Mon Dec 04, 2017 1:11 am

Re: Selecting text from locked field

Postby sandrobilbeisi » Sat Dec 30, 2017 5:06 am

If there were a programmatic way to create HLinks ,

I could eliminate the need for hypertextual text groups ---

oh gazooks !!

I just discovered the insertFieldHyperlink eternal in the XTend help project
Code: Select all
InsertFieldHyperLink(<fldDescriptor>, <selStart>, <selEnd>[, <URL>[, <imagePath>]])
sandrobilbeisi
 
Posts: 35
Joined: Mon Dec 04, 2017 1:11 am

Re: Selecting text from locked field

Postby JoeKoomen2011 » Sat Dec 30, 2017 6:44 am

You can also use the Group keyword (usage 2 in the help guide) to create clickable links.

Here is a script by Stephane Leys that I use to create links in an editable field to go to other cards that are mentioned in the field.

Link menuItem Script
Code: Select all
on itemSelect
  global gActiveField
  put the short name of gActiveField into tFieldName
  set the textStyle of bg fld tFieldName to underline, group
  set the textColor of gActiveField to 253
  pass itemSelect
end itemSelect


Script for the field
Code: Select all
on clickinfield
  link
end clickinfield

on openfield
  link
  pass openfield
end openfield


In the project script
Code: Select all
on link
  global gWdList
  if not mouseOnLink() then return ""
  put target() into tfld
  lock screen
  set lockmessages to true -- lockmessages here would filter close/leavefield
  set locktext of tfld to true
  -- set lockmessages to true -- lockmessages here filters mousedown/up
  click at  clickloc()
  set locktext of tfld to false
  set lockmessages to false
  put clicktext() into tOpen
  repeat for each line tWd of gWdList
    try
        do merge("open cd `[[tOpen]]` of [[tWd]]")
        put true into b
      catch
        put false into b
    end try
    if b then exit repeat
  end repeat
  put the short name of topWindow() into tWindow
  set the selectedCard of window tWindow to tOpen
end link
Joe Koomen
>> Random! ...Damn near killed 'em! <<
User avatar
JoeKoomen2011
 
Posts: 470
Joined: Thu Mar 12, 2009 1:38 pm


Return to Scripting in SuperTalk

Who is online

Users browsing this forum: No registered users and 1 guest

cron