hilighting text

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 491
Joined: Thu Nov 13, 2008 6:48 am
Location: Winnipeg, Manitoba

hilighting text

Post by marksmithhfx » Wed Oct 12, 2011 3:32 am

Hi, does anyone know how to hilite (or hilight) an arbitrary portion of text in a field under script control? So, for example, if i want to hilite from char 5 to char 10 in field 1 what command could I use to do that? It is probably something very very obvious that I am overlooking so thanks for your suggestions.

-- Mark
macOS 10.14.2 Mojave, Xcode 10.1, LC 9.0.4, iOS 11.4.1
Targets: Mac, iOS

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Location: California
Contact:

Re: hilighting text

Post by dglass » Wed Oct 12, 2011 4:03 am

select character 5 to 10 of field 1

AndyP
Posts: 470
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: hilighting text

Post by AndyP » Wed Oct 12, 2011 1:26 pm

Nearly... try

select character 5 to 10 of fld "field 1"
put the selectedtext into fld "field 2"
Andy Piddock

http://2108.co.uk/tinyide/ - Mini LC IDE alternative

http://2108.co.uk/script-editor-themer/ - Script Editor colour theming

http://livecodeshare.runrev.com/stack/897/LiveCode-Multi-Search - Search across 8 LC resources

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 491
Joined: Thu Nov 13, 2008 6:48 am
Location: Winnipeg, Manitoba

Re: hilighting text

Post by marksmithhfx » Thu Oct 13, 2011 2:02 am

Thanks guys... I was overthinking this one. I was looking everywhere for a "hilite" command and couldn't find it... so "select" is the ticket.

Thanks

-- Mark
macOS 10.14.2 Mojave, Xcode 10.1, LC 9.0.4, iOS 11.4.1
Targets: Mac, iOS

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: hilighting text

Post by WaltBrown » Thu Oct 13, 2011 6:00 am

Mark,
I've used backColor character by character to track multistage parsing of large texts for version changes, keywords, phrases, proper names, etc. It can get cumbersome, but I needed to track many separate iterative parsing processes and it was easier than setting up a database or XML trees, once I had the subroutines built.
Walt
Walt Brown
Omnis traductor traditor

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 491
Joined: Thu Nov 13, 2008 6:48 am
Location: Winnipeg, Manitoba

Re: hilighting text

Post by marksmithhfx » Sun Oct 16, 2011 11:52 pm

HI Walt, something interesting I've noted (which is somewhat of a limitation in LC). When you highlight some text in a normal editing field and then do a right mouse click to popup a menu (this tested on a Mac), the highlighting disappears (and no attempt to get it back on my part has been successful). This does not conform to the way most applications function in such a situation. Normally the text remains highlighted while the popup has the focus.

Have you seen a way to circumvent this problem?

PS thanks for the advice re: highlighting keywords, phrases, proper names, etc. I'll keep the technique in mind (though it sounds painful :( )
macOS 10.14.2 Mojave, Xcode 10.1, LC 9.0.4, iOS 11.4.1
Targets: Mac, iOS

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: hilighting text

Post by Dixie » Mon Oct 17, 2011 12:56 am

Hi Mark...

I have attached a stack that will get you started with keeping the highlight of the text in conjunction with a popUp menu...

be well

Dixie
Attachments
keepHilight.livecode.zip
(1.16 KiB) Downloaded 164 times

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 491
Joined: Thu Nov 13, 2008 6:48 am
Location: Winnipeg, Manitoba

Re: hilighting text

Post by marksmithhfx » Mon Oct 17, 2011 4:12 am

Dixie wrote:Hi Mark...

I have attached a stack that will get you started with keeping the highlight of the text in conjunction with a popUp menu...

be well

Dixie
Oh how clever!! Now why didn't I think of that :) Dixie stikes again. Thanks for posting!
macOS 10.14.2 Mojave, Xcode 10.1, LC 9.0.4, iOS 11.4.1
Targets: Mac, iOS

WaltBrown
Posts: 466
Joined: Mon May 11, 2009 9:12 pm
Location: NE USA

Re: hilighting text

Post by WaltBrown » Thu Oct 20, 2011 1:50 am

I'll try Dixie's stack, but what I saw was that if you set the backColor by character, word, or line, the result when you tested for the backColor of a word was inconsistent, almost as if characters, words, and lines had separate backColor settings. I don't have a clear enough understanding of the dynamics yet to offer a decent explanation.
Walt
Walt Brown
Omnis traductor traditor

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”