prevent field text "flicker" when using openfield

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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

prevent field text "flicker" when using openfield

Post by billworld » Mon Dec 01, 2008 2:23 am

When tabbing into some fields, I need the text to be highlighted. The following code does this, however, there's an annoying flicker which occurs. It appears that the cursor first gets positioned at the end of the text then the text gets highlighted, thus the "flicker". Is there a way around this?

Thanks

Code: Select all

on openfield
    select text of me
end openfield

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Dec 01, 2008 10:58 pm

Hi Bill,

instead of using the openField message, use the tabkey message. Of course, you will have to write a different script for each field or apply some trick with cursom properties.

Code: Select all

on tabKey
  select text of fld "Next Field"
end tabKey
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Post by billworld » Mon Dec 01, 2008 11:43 pm

That approach is not practical. It also doesn't help with tabbing backward (shift-tab). Anyway, I'll just deal with the flicker and post a QCC report. Thanks anyway.
Mark wrote:Hi Bill,

instead of using the openField message, use the tabkey message. Of course, you will have to write a different script for each field or apply some trick with cursom properties.

Code: Select all

on tabKey
  select text of fld "Next Field"
end tabKey
Best,

Mark

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Dec 01, 2008 11:59 pm

Hi Bill,

Why is't it practical? You have to write a script to make it practical. You can expect that Rev does everything for you.

You didn't say you want it to go the reverse if the shiftkey is pressed. You can check whether the shiftkey is pressed in your script and select the text of a different field.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Tue Dec 02, 2008 12:17 am

More importantly, what operating system/environment do you have? There's various quirks in the display (that for instance, lockscreen doesn't prevent, although I believe it should) on my runtimes in various ways, but I get no flicker at all in testing your original openField script.
Granted, it's only one card, but I made several very large fields and they all tabbed and selected with no quirk in the display.
I use Rev Studio 3 on Windows XP, mainly.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Tue Dec 02, 2008 12:50 am

bill,
this works if you put it into the script of a card (based on Marks suggestion)

Code: Select all

local tLastFieldNumber
on tabKey
    put the number of fields into tFieldNumbers
    if tLastFieldNumber is "" then put 0 into tLastFieldNumber -- first time
    if the shiftkey is not down then
        if tLastFieldNumber < tFieldNumbers then 
            add 1 to tLastFieldNumber
            select text of field tLastFieldNumber
        else
            put 1 into tLastFieldNumber
            select text of field tLastFieldNumber
        end if
    else -- shiftKey is down
        if tLastFieldNumber > 1 then 
            subtract 1 from tLastFieldNumber
            select text of field tLastFieldNumber
        else 
            put tFieldNumbers into tLastFieldNumber
            select text of field tLastFieldNumber
        end if
    end if
end tabKey
almost no flicker with this. Although the flicker is barely noticeable on my Mac 2.2 Mhz. Give your user a nickel if he notices the flicker (as an incentive) :)
bernd

susiRMIT
Posts: 6
Joined: Mon Dec 01, 2008 8:35 am

Post by susiRMIT » Tue Dec 02, 2008 3:00 am

Hi bn,

I applied your code but I must press tab key two times then cursor moves to another field.

Plz help me. Thanks

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Dec 02, 2008 6:02 am

You can also let the engine do the hiliting whenever the user 'tabs' between fields. Select your field, open the Inspector and tick the checkbox 'Tab on return' in the 'Basic properties' panel - or if you'd rather do it by script

Code: Select all

set the autoTab of field "foobar" to true
HTH,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

susiRMIT
Posts: 6
Joined: Mon Dec 01, 2008 8:35 am

Post by susiRMIT » Tue Dec 02, 2008 10:14 am

It's OK now. Thanks :wink:

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Tue Dec 02, 2008 1:23 pm

Jan Schenkel wrote:
You can also let the engine do the hiliting whenever the user 'tabs' between fields. Select your field, open the Inspector and tick the checkbox 'Tab on return' in the 'Basic properties' panel - or if you'd rather do it by script
that works perfectly, without the hassle of scripting the tab or openfield and Bill, no FLICKER.

Bernd

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Tue Dec 02, 2008 1:27 pm

Hi,

That's a great solution, but note that the field layers have to be in a particular order for this to work.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Post by billworld » Wed Dec 03, 2008 5:07 am

Thanks Jan. Odd, but, that works! How do you know this stuff? I guess you stumbled on it one day?

While it shouldn't be an issue for most of my fields, losing the ability to use the Return key to generate a carriage return within a field may be a concern (for larger text fields). But, as that may be the exception rather than the norm, other techniques could be used for that.

But, regardless, your technique provides the highlight without flicker nice and easy.

Thanks!

Bill
Janschenkel wrote:You can also let the engine do the hiliting whenever the user 'tabs' between fields. Select your field, open the Inspector and tick the checkbox 'Tab on return' in the 'Basic properties' panel - or if you'd rather do it by script

Code: Select all

set the autoTab of field "foobar" to true
HTH,

Jan Schenkel.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Wed Dec 03, 2008 6:29 am

I'm not even sure where I got that information - it must have come up on the use-revolution list at one point and it stuck in my head (which is odd, as I usually have the memory of a goldfish)

It's a funky property, as it allows the user to only enter a return if it doesn't cause the field to 'scroll' - so if you have a field that is tall enough to hold 4 lines of text, then the user can enter up to 4 lines of text and the next time he hits the return key the focus will jump to the next field.

But the jump to the next field and the hiliting behaviour is great for data entry forms as you don't have to go about and script individual 'tabKey' and 'returnInField' handlers to move things on their merry way.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

billworld
Posts: 188
Joined: Sat Oct 25, 2008 12:32 am

Post by billworld » Wed Dec 03, 2008 6:37 am

Excellent. Thanks for the clarification on the return key. Awesome tips here. They're now in my personal RR notes db.

Thanks

Bill
Janschenkel wrote:I'm not even sure where I got that information - it must have come up on the use-revolution list at one point and it stuck in my head (which is odd, as I usually have the memory of a goldfish)

It's a funky property, as it allows the user to only enter a return if it doesn't cause the field to 'scroll' - so if you have a field that is tall enough to hold 4 lines of text, then the user can enter up to 4 lines of text and the next time he hits the return key the focus will jump to the next field.

But the jump to the next field and the hiliting behaviour is great for data entry forms as you don't have to go about and script individual 'tabKey' and 'returnInField' handlers to move things on their merry way.

Jan Schenkel.

Post Reply