Tuesday, December 12, 2017

#1 2016-06-23 05:06:53 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Disappearing text field placeholders

I'm having this issue where my text field placeholders are disappearing when I run the app.

The is what it looks like in the Interface Builder:
N6peFBN.png

This is what you see when the app runs:
isrpEOQ.png

Offline

 

#2 2016-06-24 11:33:47 am

Mark FX
Member
From:: UK
Registered: 2011-08-12
Posts: 94

Re: Disappearing text field placeholders

This works OK with the latest OSX 10.11.5, and with an Xcode 7.3 project.
I was unable to reproduce your problem.

Which version of OSX and Xcode are you using ?
Because there may have been a glitch with earlier versions of each, but can't remember oiff the top of my head.

The only way I could reproduce this problem, was to format the string value of the Text Field in some way.
Make sure your not displaying invisible characters in the Text Field, e.g. an empty space, or carriage return, as
this will invalidate the placeholder text.

If you have any code relating to the Text Field, it might be worth commeting out all of this code, and running
the project each time you uncomment a line of the code, this may highlight the problem.

Regards Mark

Last edited by Mark FX (2016-06-24 11:34:48 am)

Offline

 

#3 2016-07-05 05:36:45 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Re: Disappearing text field placeholders

Mark FX wrote:

This works OK with the latest OSX 10.11.5, and with an Xcode 7.3 project.
I was unable to reproduce your problem.

Which version of OSX and Xcode are you using ?
Because there may have been a glitch with earlier versions of each, but can't remember oiff the top of my head.

The only way I could reproduce this problem, was to format the string value of the Text Field in some way.
Make sure your not displaying invisible characters in the Text Field, e.g. an empty space, or carriage return, as
this will invalidate the placeholder text.

If you have any code relating to the Text Field, it might be worth commeting out all of this code, and running
the project each time you uncomment a line of the code, this may highlight the problem.

Regards Mark


The properties for the variables are like this.

Applescript:


property PONumber: missing value
property PolicyCost: missing value
property PolicyTerm: missing value
property InvoiceNumber: missing value
property ProductCode: missing value
property ProductMake: missing value
property ProductModel: missing value
property FullDescription: missing value
property SerialNumber: missing value
property PriceExVAT: missing value
property Forename: missing value
property Surname: missing value
property Email: missing value
property Address1: missing value
property Address2: missing value
property Address3: missing value
property Address4: missing value
property Address5: missing value
property PostCode: missing value
property PurchaseDate: missing value

I can't imagine why they would be doing this. I'm using all the latest software, it even does it in Xcode 8 beta.

Edit: Definitely has something to do with the binding but I have no idea.

Last edited by krwllms (2016-07-05 05:40:36 am)

Offline

 

#4 2016-07-05 06:44:49 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Disappearing text field placeholders

You can't have placeholder text when you use bindings. The problem is that once the contents is bound to some value, it no longer considers itself without a value, hence it doesn't show the placeholder text.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#5 2016-07-05 07:40:16 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Re: Disappearing text field placeholders

Shane Stanley wrote:

You can't have placeholder text when you use bindings. The problem is that once the contents is bound to some value, it no longer considers itself without a value, hence it doesn't show the placeholder text.


Oh... How do I connect the text fields to a variable whilst still having a placeholder then?

Offline

 

#6 2016-07-05 07:47:13 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Disappearing text field placeholders

krwllms wrote:

Oh... How do I connect the text fields to a variable whilst still having a placeholder then?


You can't. If you want to use placeholders, you have to change the values in code using setString:.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#7 2016-07-06 04:59:09 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Re: Disappearing text field placeholders

Shane Stanley wrote:

You can't. If you want to use placeholders, you have to change the values in code using setString:.


How would I go about updating a variable's value using a text field like I'm trying to do?

Offline

 

#8 2016-07-06 06:17:37 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Disappearing text field placeholders

You need to have properties for each text field, set to missing value. You then need to make them outlets for text fields, which you can do by control-dragging from a text field to the icon representing your file (probably the app delegate), and choosing the property in the list that appears.

Then you set the value to appear like this:

Applescript:

someTextField's setStringValue:"A string"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#9 2016-07-06 07:35:19 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Re: Disappearing text field placeholders

Shane Stanley wrote:

You need to have properties for each text field, set to missing value. You then need to make them outlets for text fields, which you can do by control-dragging from a text field to the icon representing your file (probably the app delegate), and choosing the property in the list that appears.

Then you set the value to appear like this:

Applescript:

someTextField's setStringValue:"A string"


Doesn't this update the contents of the text field? I want to go the other direction. I want to use the text entered into the text field as the value of a variable. I want to pass the text entered in the text field to a variable.

Offline

 

#10 2016-07-06 07:37:48 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: Disappearing text field placeholders

Then use:

Applescript:

set theString to someTextField's stringValue()

And add "as text" if you want an AppleScript string.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#11 2016-07-06 07:56:16 am

krwllms
Member
Registered: 2016-01-28
Posts: 14

Re: Disappearing text field placeholders

Thank you.

Offline

 

#12 2016-07-12 07:22:22 am

IanMcP
Member
From:: Newcastle, UK
Registered: 2006-10-19
Posts: 83

Re: Disappearing text field placeholders

In the bindings, under Value, set your Null Placeholder to whatever value you want displayed when the field is not populated or in use

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)