No auto hightlight part of TextField Text with Floating Window

Hi,
[sorry: in the title, I do the auto part]

I changed the kind of window from Document to Floating Window (OS X 10.9.4) and loose a special feature:

in a TextField, I display an URL (where to go) in a Desktop application.

If the URL holds a date (&dat=) tag, I highlight the date so I can change it without searching it.

This is the feature I lost.

Is it a bug or a Feature ?
(Nota: I do not checked the Windows status for this feature).

PS: fortunately, I do not trashed the previous standalone, so it was fast for me to know what I’ve done in the mean time.

If you do a SetFocus on the textfield in the floating window, you should see your selection highlight.

e.g. if your floating window is of class Window2, and the text field on it is called TextField1, then do this:

Window2.TextField1.SetFocus

Hi Hamish,

Thank you for your kind answer.

Language barrier (or I am tired):

I want to get the date to be highlighted (from an URL).

If the window kind is Floating Window, the whole text is highlighted and that is not what I want.

Hello,

To highlight some text you need to set the .selstart and .sellength properties of the text field.

So, if you have your URL:
http://www.example.com?something=value&dat=20140729&somethingelse=value2

in a textfield called TextField1, you would want to do something like this:

TextField1.SelStart = 43
TextField1.SelLength = 8
TextField1.SetFocus

I guess you already have code to work out where in the string the ‘dat’ value is? Perhaps you can post that code, if this reply doesn’t help you?

Hi Hamish,

sorry for my poor english.

The problem does not comes from the code, but from the king of window.

Same code, Document window, what I want is correctly highlighted (the 8 characters after the&dat= string: the date).

If I change the window kind from Document to Floating Window, that code no more do its job.

OK. Without seeing the code I’m not going to be able to be much help; could you show me the code, please?
H

[quote=115737:@Emile Schwarz]Hi Hamish,

sorry for my poor english.

The problem does not comes from the code, but from the king of window.

Same code, Document window, what I want is correctly highlighted (the 8 characters after the&dat= string: the date).

If I change the window kind from Document to Floating Window, that code no more do its job.[/quote]

Post your code.

You ask for it, here you are:

Dim TheURL As String
Dim DateStart As Integer

TheURL = TF_Set_URL.Text
DateStart = InStr(TheURL,"&dat=")
If DateStart > 0 Then
DateStart = DateStart + 4

TF_Set_URL.SelStart = DateStart
TF_Set_URL.SelLength = 8

End If

TF_Set_URL is a TextField
TF_Set_URL is filled at window Open time with the URL of the current page.

I just checked:
If I set that window property:
Frame --> Type --> Document

I got the date highlighted: what I want. I can press the right arrow, delete key and set the next day or type a totally new date (like 20140729 instead of 19250112).

If I set:
Frame --> Type --> Floating Window

All the URL is highlighted (I do not care if there was not a date in the URL, but there is one).

I access to some goolge server that have a date in the url that allows me to get data from that date.

Hi -

As I said in my first post, you need to setfocus on the text field.

Put

TF_Set_URL.SetFocus

after the line

TF_Set_URL.SelLength = 8

and it should work.

Agh, I’m so sorry, I replied far too fast to that one. SetFocus probably won’t do anything.

I have tried it with the following code. I have two Windows in a project.

Window2 is a new Window class, and contains a text field called TF_Set_URL.

Window1 is a new Window class, and contains one pushbutton. In that pushbutton, I have put the following code:

[code] dim w as window2 = new window2

Dim TheURL As String
Dim DateStart As Integer

w.show

w.TF_Set_URL.Text = “http://www.fish.com/sdf?something=true&dat=20140101&sometingelse=true
theURL = w.TF_Set_URL.Text
DateStart = InStr(TheURL,"&dat=")
If DateStart > 0 Then
DateStart = DateStart + 4

w.TF_Set_URL.SelStart = DateStart
w.TF_Set_URL.SelLength = 8

End If

w.TF_Set_URL.SetFocus[/code]

And the date is highlighted. I can’t get it to highlight the entire URL at all.

[quote=115976:@Hamish Symington]And the date is highlighted. I can’t get it to highlight the entire URL at all.
[/quote]

Looks like a bug :frowning:

I just found a way to render modal a document window, and posted it there https://forum.xojo.com/14256-movable-modal-dialog

Could be a possible workaround for this issue.

Without seeing the full code, including that which shows the window, I can’t really be of any help here, I’m afraid…

It does something: it select all the text (in a Document window), so exactly what I do not want…

Window1.Show

Return True

The window is called from a MenuHandler…

That is what I want.

OK. Can you please try the code I posted above, in a new project with just two windows, and see if you can get that working?

Oh ! I do not run the code from a button, but from the Activate event. I recall having done it in the Open event, but if I go out of the application (who is full screen) to do something else and come back, the whole URL is selected instead of just the date.

What you (all) do not understand is that the code works fine if the window is of type Document. If I cange that, the code works no more.

I will try your code right now.

I do understand that the code is fine if the window is a document window; I’m trying to help you work out why it might not be happening for a Floating window.
I’ve just tried my code in the Activate event of the application and it’s fine. I’m running 2012 r2.1 on Mac OS 10.9.
H

Code checked and it does not works.

Here’s a screen shot of what my code does (and Window Type is Document):

Here is Xojo 2014r2 / 10.9.4.

I rechecked after setting Window2 to Floating Window: nothing.

I am sorry if one of my previous answers can sound rude, it was not intended, sorry.

OK; I’m afraid I can’t help, because it looks like it might be a difference in behaviour between 2012r2.1 and 2014r2, and I don’t have 2014r2 on this machine.

It didn’t sound rude, don’t worry! I was just trying to let you know that I’d understood the problem that you were having.