Page 1 of 1

Custom time format isn't editable

Posted: Mon Feb 10, 2020 2:06 am
by brendan.ratcliffe
Hi,

I'm having trouble editing the text in a standard text widget while the format is set to a custom time, for example if I set the format in the widget to:

%Y-%b-%d %H:%M:%S

The format previews correctly as:

2020-Feb-10 12:56:16

However in the widget itself, the text defaults to some time between "1970-Jan-01 23:00:00" and "1970-Jan-01 23:59:59". The minutes and seconds portion of the text field are editable however the other sections aren't. They just revert back to whatever they were before. This same behaviour is true when I try to set the text field value using the "text()" function. The preset time format options work as expected, however.

Thanks,

Brendan

EDIT: I am using V3.15 and have recreated this bug on both Redhat and Windows.

Re: Custom time format isn't editable

Posted: Tue Feb 11, 2020 9:14 am
by leoknipp
I had a look at the description but I do not understand the following part: ... the text defaults to some time between "1970-Jan-01 23:00:00" and "1970-Jan-01 23:59:59".

What does it mean in detail?
Which time is set when you "the defaults"

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Custom time format isn't editable

Posted: Thu Feb 13, 2020 11:10 pm
by brendan.ratcliffe
Hi Leo,

What I mean is that the text within the text field is automatically set to some time between those two times and cannot be changed to any time outside of those times. Entering any string combination into the text field resolves to some time between those two times mentioned once focus on the text field has been lost.

For example, if the text in the text field reads "1970-Jan-01 23:00:00" and I manually change the "1970" portion of the text to "1971", the change applies until the text field loses focus (by either pressing enter or by clicking somewhere else in the application). Once the text field loses focus, the time reverts back to the original "1970".

The same situation applies if I try to change the month (to 'Feb', 'Mar', 'Apr') , day, or hour within the text field.

Note that I have no scripts defined on this text field.

Hopefully that makes sense, it's really odd behavior.

Thanks,

Brendan

Re: Custom time format isn't editable

Posted: Fri Feb 14, 2020 12:58 pm
by dbindernagel
I had a look at this and I encounter the problem, too (Used version: 3.14 P22).

I tried some options and I have found the following:

Recreate the problem:
1.1 Create a panel with a "TEXT_FIELD".
1.2 Set the "Text Format" to "Time" and then Custom (in group box "Format") and enter the custom format:
%Y-%b-%d %H:%M:%S
1.3 Run the panel and try to enter a time in the specified format, e.g.: 2020-Jan-01 01:01:01
Result: The time displayed in the TEXT_FIELD is set to a value with date "1970-Jan-01" and "random" time.

Workarounds (but depending on your requirements probably not usable):
1.
The "TEXT_FIELD" only handles inputs correctly that are using the "default" time format.
With default time format I mean the time format that is originally selected when first setting the format to "Time" (the first option on the top):
YYYY.MM.DD HH:MM:SS.mmm

Time entered in this format will be handled correctly, e.g.: 2020.01.01 01:01:01.000
After entering the time and pressing enter the TEXT_FIELD is then displaying the entered time in the selected custom format.

2.
It is also possible to set a time by writing a time variable to the text, e.g.:

Code: Select all

main()
{
  time t = getCurrentTime();
  TEXT_FIELD1.text = t;           
}
You can also enter an integer that represents the (unix) time but only via a script. Entering the integer in the TEXT_FIELD manually results in the same problem as above.

Code: Select all

main()
{
  TEXT_FIELD1.text(1577836861);
}
But these are just workarounds. The TEXT_FIELD should handle time values entered in the custom format correctly.

Re: Custom time format isn't editable

Posted: Mon Feb 17, 2020 12:46 pm
by leoknipp
I have tested it and I can reproduce the problem.
This issue was forwarded to our developement department with low priority.

Instead of typing the time/date in the text field you can open a data/time selector and let the customer choose the required time.

Best Regards
Leopold Knipp
Senior Support Specialist

Re: Custom time format isn't editable

Posted: Mon Feb 17, 2020 11:10 pm
by brendan.ratcliffe
Thanks for the replies.

The current workaround I've implemented is to set the text_field format to a string and use the patternMatch() function to ensure that the string in the text box is of the desired format. It means that the users of our system have to individually highlight and change the characters of the text box, but it works for now until the issue is fixed.

@leoknipp
Instead of typing the time/date in the text field you can open a data/time selector and let the customer choose the required time.
This was the initial approach to getting a datetime, but we ran into issues with that EWO crashing our Vision UI completely. That is a whole other problem that I suspect will be difficult to diagnose, so not wanting to waste any more time on it we used a text box widget and use the 'clicked' script to spawn a calendar object.

Re: Custom time format isn't editable

Posted: Wed Feb 19, 2020 4:39 pm
by leoknipp
Instead of the EWO you can possibly also use the panel vision/dateTimePicker.pnl to have the ability to select a date and time.

Best Regards
Leopold Knipp
Senior Support Specialist