Textfield data persistance

I have 2 textfields with 2 buttons. When a button is clicked the user can pick a directory by means of the default SelectFolder dialog.
If F <> nil then the path is entered in textfield1. When I repeat the same with textfield2 the info in textfield1 disappears after closing the SelectFolder dialog.

I double checked for naming errors etc.

How come?

Without you posting a snippet of your code under the button action event that handles that textfield2, I don’t think we could help much on this one… especially since you’ve already double-checked object reference names.

Hi Eric

[code]Sub Action()
Dim f As FolderItem

f = SelectFolder
If f <> Nil Then
fpclocatieFld.text = f.NativePath
End If

End Sub
[/code]

[code]Sub Action()
Dim f As FolderItem

f = SelectFolder
If f <> Nil Then
productielocatieFld.text = f.NativePath
End If

End Sub[/code]

I changed it into:

Dim f As FolderItem Dim tempEdit as String tempEdit = fpclocatieFld.text f = SelectFolder If f <> Nil Then productielocatieFld.text = f.NativePath End If fpclocatieFld.text = tempEdit

in order to restore the data in the other field after returning from SelectFolder (and for the other button vice versa)

Hmmm… that is strange. I wonder if this is some kind of scope/destruct issue w/ the folderitem. Try this and see if it still happens (store the path into a string first, then reference the string with the textfield value):

[code]
Sub Action()
Dim f As FolderItem
Dim p As String

f = SelectFolder
If f <> Nil Then
p = f.NativePath
fpclocatieFld.text = p
End If

End Sub[/code]

[quote=129464:@Alexander van der Linden]I changed it into:

Dim f As FolderItem Dim tempEdit as String tempEdit = fpclocatieFld.text f = SelectFolder If f <> Nil Then productielocatieFld.text = f.NativePath End If fpclocatieFld.text = tempEdit

in order to restore the data in the other field after returning from SelectFolder (and for the other button vice versa)[/quote]

Yeah, that is leading me to conclude it is a scope/deconstruct issue w/ the folderitem (or more specifically, the select folder portion of it). I’m not sure if this is by design to behave this way, but if so… I’d like to know the reasoning behind it. Assigning a value to the textfield itself should have retained that value within the textfield object, even if whatever it pointed to deconstructed. Nothing caused the textfield targets to fire an update to change its value (at least, not on our side of things) after the folderitem deconstructed itself.

No, it’s gone if I use your code…

I just created a new project with 2 buttons and 2 text fields, pasted your code in and it works as I would expect. The text in TextField1 does not disappear when I select a folder for TextField2. Are you sure you don’t have code elsewhere (perhaps another event?) that is removing the text?

Sample Project

Hi paul,

I had done that myself and concluded that it is working as expected. Though in my other project it does not. I checked if any other events were influencing the text but none whatsoever.

No harm done, just a minor issue, I fixed it as in Eric’s code.