Focus on nothing not working on Windows? [SOLVED]

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Focus on nothing not working on Windows? [SOLVED]

Post by stam » Mon Jul 26, 2021 11:31 am

Hi all,
Slight cosmetic issue with 'focus on nothing' on Windows.

I'm building one of my apps on a Mac, but mainly intended to run on Windows.
After a splash stack initialises the main stack, this brings up a login card - i have fields with placeholder text in the username/password fields. This placeholder text disappears when entering the field, so this doesn't show if the field has the focus.

On Mac, i can just run 'focus on nothing' and both fields show their placeholder text.
On Windows, the last field always has the focus, hiding it's placeholder text - which is annoying.

Here's what it's supposed to look like:
login.jpg
Any suggestions to not allow any of the fields to get the focus after initialising?
Last edited by stam on Tue Jul 27, 2021 8:17 pm, edited 2 times in total.

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Focus on nothing not working on Windows?

Post by andresdt » Mon Jul 26, 2021 4:08 pm

Hello,
Here is a sample stack, although it is not exactly like the image, you already have an idea of how to do it.
Hope this helps you.
Attachments
loginUI.rar
(1.64 KiB) Downloaded 125 times

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Focus on nothing not working on Windows?

Post by jacque » Mon Jul 26, 2021 5:22 pm

Does "select empty" work any better?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Focus on nothing not working on Windows?

Post by andresdt » Mon Jul 26, 2021 5:52 pm

Hope this does help you.
Attachments
loginUI-1.rar
(3.68 KiB) Downloaded 105 times

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Focus on nothing not working on Windows?

Post by stam » Mon Jul 26, 2021 6:31 pm

Thanks @andresdt - i must be a bit dense today tho, how does this stop the fields from getting the focus on Windows?

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Focus on nothing not working on Windows?

Post by stam » Mon Jul 26, 2021 6:42 pm

jacque wrote:
Mon Jul 26, 2021 5:22 pm
Does "select empty" work any better?
I'll try that when I'm at a windows work machine again - the rate limiting step for me is i don't have an easily accessible Windows machine for testing and in any case cannot replicate the locked down environment at the target machine, so i have build, transfer, test, fail and repeat :(
getting there though!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Focus on nothing not working on Windows?

Post by FourthWorld » Mon Jul 26, 2021 9:19 pm

"Focus on nothing" is not intended to be an executable statement in a script. It's a reminder for the scripter. Practiced with earnestness, it can help you transcend any need to worry about trying to make Windows look attractive. ;)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Focus on nothing not working on Windows?

Post by SparkOut » Mon Jul 26, 2021 9:44 pm

FourthWorld wrote:
Mon Jul 26, 2021 9:19 pm
"Focus on nothing" is not intended to be an executable statement in a script. It's a reminder for the scripter. Practiced with earnestness, it can help you transcend any need to worry about trying to make Windows look attractive. ;)
I had to read that twice before I saw what you did there.
If you had included a big image, I might have thought you were channelling Richmond.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Focus on nothing not working on Windows?

Post by jacque » Mon Jul 26, 2021 9:54 pm

One more possibility: It's a result of LC's (irritating) auto-select of the first editable field when a card opens. If your password field is the first-layered one then that could be what's happening, though in theory it should do the same thing on Mac too. The workaround is to turn off traversalOn in preOpenCard and turn it back on using a "send" command after openCard finishes.

This probably isn't the reason since it doesn't happen on Mac, but maybe the workaround will fix it anyway. Another Windows-only workaround is to put a button at a lower level than the fields. On Windows, buttons can have traversalOn and the button would get the selection instead of the field.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

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

Re: Focus on nothing not working on Windows?

Post by SparkOut » Mon Jul 26, 2021 10:09 pm

Just for the record

Code: Select all

focus on nothing
is tested working on Windows here, using a basic stack.
I am not sure what is going on in the OP's stack, but it shouldn't need jiggery-pokery to work, but then there's jiggery-pokery going on with the placeholder text construction.
Last edited by SparkOut on Mon Jul 26, 2021 10:14 pm, edited 1 time in total.

andresdt
Posts: 146
Joined: Fri Aug 16, 2019 7:51 pm

Re: Focus on nothing not working on Windows?

Post by andresdt » Mon Jul 26, 2021 10:13 pm

Apparently I need to sleep!
I don't know if I understand your problem.
what you want is that when entering the login card the username field is selected?

If that's, you can do like this:

Code: Select all

on openCard
    focus on field "username" of me
end openCard
then in the username field you can put:

Code: Select all

on enterInField
    focus on field "password" of this card
end enterInField

on returnInField
    enterInField
end returnInField

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Focus on nothing not working on Windows?

Post by jacque » Tue Jul 27, 2021 5:38 pm

Not exactly. When the card opens he wants nothing selected. LC auto-selects the first editable field and if that's what's happening then it's interfering with the default hint text for that field. There may be a timing issue involved.

If none of the suggestions here work, I think I'd send a specific command to show hint text after the card opens.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 2679
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Focus on nothing not working on Windows?

Post by stam » Tue Jul 27, 2021 8:16 pm

Thanks @jacque

Timing was probably the issue in the standalone.
I have a card handler does some init stuff for the login fields and ends with 'focus on nothing'. I call this directly at the end of openStack. In the IDE this works fine but on the Win stand alone it didn't, leaving the focus on a field and spoiling the placeholder text effect.

This is what it's supposed to look like
ideal.jpg
This is what actually happened no matter what the code
reality.jpg
Just annoying enough ;)

Taking a cue from Jacque's suggestion, Instead of call the handler directly, i tried using

Code: Select all

send <init-handler> to me in 0.5 seconds
and it works fine.
Well, fine-ish, as there is a quick flash where the field does get the focus but at this point i'll live with that.

Thanks all!
Last edited by stam on Wed Jul 28, 2021 8:24 am, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Focus on nothing not working on Windows? [SOLVED]

Post by FourthWorld » Tue Jul 27, 2021 9:32 pm

Stam, is that for Mayo?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7227
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Focus on nothing not working on Windows? [SOLVED]

Post by jacque » Tue Jul 27, 2021 11:06 pm

I wonder if a lockscreen would overcome the flash.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”