You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, December 21st 2017, 9:22am

textfield devicedepending attributes

I just startet to use "attribute.xxx=..." xml-definition code in future for better readable code (xxx means e.g. "normar", "desktop.or.tablet", and so on).
But i have problems with this using dynamic added layers type "text":

definitions like:
set(plugin[myText].autowidth.normal, true);
set(plugin[myText].css.mobile, 'css here...');
set(plugin[myText].width.desktop.or.tablet, 200);
don´t work.

Is it not possible to use those device attributes within layers of the plugin type text?
Or is it not possible to use them within any dynamic added code?
best regards from www.PanAustria.com

2

Thursday, December 21st 2017, 10:16am

i dont think that works in dynamic code
guess you must do it like this
if(device.desktop OR device.tablet, set(plugin[myText].width, 200));

toosten

Intermediate

Posts: 469

Location: Berlin

Occupation: freier Software-Entwickler ( HTML, JS, PHP, JSP, Flash, AS3, C++, Java, krpano, ---)

  • Send private message

3

Thursday, December 21st 2017, 10:18am

https://krpano.com/docu/actions/#device.normal

if( device.normal, set(plugin[myText].autowidth, true));
if( device.mobile, set(plugin[myText].css, 'css here...'));


if( device.desktop, set(plugin[myText].width, 200));
if( device.tablet, set(plugin[myText].width, 200));

or

if((device.desktop) OR (device.tablet), set(plugin[myText].width, 200));

4

Friday, December 29th 2017, 9:23am

Thank you both for your reply!
I know the workaround as well -
...would be fine to here from Klaus if this is a (known/unknown) bug or part of the concept.
Consequently I would expect this to work because it eases coding as well as readability and in my understanding those were the goals for the new syntax...

Best regards,
Panaustria
best regards from www.PanAustria.com

toosten

Intermediate

Posts: 469

Location: Berlin

Occupation: freier Software-Entwickler ( HTML, JS, PHP, JSP, Flash, AS3, C++, Java, krpano, ---)

  • Send private message

5

Friday, December 29th 2017, 11:14am

Wenn Du das direkt in XML definierst, dann funktioniert es, aber nicht im dynamischen Actions-Bereich.
Du könntest diese Parameter auch in einem https://krpano.com/docu/xml/#style definieren und dann per https://krpano.com/docu/xml/#layer.loadstyle laden.

6

Friday, December 29th 2017, 11:18am

the condition-appendix desktop.or.tablet gets evaluated when the xml gets parsed
and plugin[myText].width gets set depending on the condition

but in an action / dynamic code you cannot use this form anymore,
this is part of the concept and not a bug, i m sure.

7

Friday, December 29th 2017, 6:41pm

the condition-appendix desktop.or.tablet gets evaluated when the xml gets parsed
and plugin[myText].width gets set depending on the condition


Thx, that answered my question. I was not aware i gets resolved while parseing - you are right! So it is no bug.
best regards from www.PanAustria.com

8

Monday, January 8th 2018, 5:38pm

Personally I think using the calc() action and the Ternary operator is a nice way to do dynamic device checks:

Source code

1
set(variable, calc(ifcheck ? thenvalue : elsevalue));
or this way (is the same):

Source code

1
calc(variable, ifcheck ? thenvalue : elsevalue);
First write the variable to check, then the value that should be used when this check is true, and then the value that should be used when not.

E.g.

Source code

1
set(plugin[test].width, calc(device.normal ? 300 : 200));


Btw - device.normal is the same as 'device.desktop OR device.tablet'.