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.

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 328

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

1

Monday, January 30th 2023, 2:23am

Correct syntax for "x.mobile=60," inside set action

Hi, please whats is wrong in the code below:
Line 39: x.mobile=60

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<action name="popup" scope="private:POPUP" args="type, content, width, height, scrollbars"><![CDATA[
		if(popup, break(); );
		
		addlayer('popup_bg', popup_bg);
		set(popup_bg,
			type=container,
			align=lefttop, width=100%, height=100%,
			zorder=99,
			handcursor=false,
			bgcapture=false,
			capture=false,
			ondown='popup_close()'
		);
			
		
		addlayer('popup', popup);
		set(popup,
			type=container,
			parent='popup_bg',
			width=calc(min(width,global.stagewidth*1)),
			height=calc(min(height,global.stageheight*1)),
			align=center,
			bgborder='1 0x555555 1',
			bgcolor=0x574e4b,
			bgalpha=0.7,
			bgshadow='0 10 20 0x000000 0.5',
			bgcapture=true,
			maskchildren=false,
			capture=true,
			handcursor=false,
			alpha=0
		);
	
		 addlayer('popup_close_x', closex);
		set(closex,

type="text",
html="CLOSE",
x.mobile=60,
y=0,
interactivecontent="true",
bgcolor="0x2D3E50",
bgalpha="0.8",
bgborder="0",
bgroundedge="1",
padding="5 5 5 5",
css="color:#FFFFFF; font-family:Arial;",
txtshadow="1"
bgshadow="0 4 10 0x000000 0.3",

			parent='popup',
			align=righttop,
			edge=righttop,
			scale=0.3,
			zorder=99,
			alpha=0.7,
			onover='tween(alpha,1)',
			onout='tween(alpha,0.7)',
			onup='tween(alpha,0.7)',
			onclick='popup_close()'
		);
		set(global.events[popup].onremovepano, popup_close() );
		set(global.events[popup].onresize, popup_close() );				
	
	]]></action>

With x=60 run ok... How to define the device in this case? (x.mobile=60 is wrong)
Thanks for your help!

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 328

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

3

Monday, January 30th 2023, 3:30pm

It dosesn't work yet...

Hi, Index, thanks for your answer. I was trying that code before but it didn't work for me: (line code 43 and 44). If I comment this line and write for example: x=60 then works fine. *confused* I also notice that in the klaus example the quotes do not appear either because it's a simplified version of "set".
(...) x.normal=60, x.mobile=0, instead x.normal="60", x.mobile="0", (...)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<action name="popup" scope="private:POPUP" args="type, content, width, height, scrollbars"><![CDATA[
		if(popup, break(); );
		
		addlayer('popup_bg', popup_bg);
		set(popup_bg,
			type=container,
			align=lefttop, width=100%, height=100%,
			zorder=99,
			handcursor=false,
			bgcapture=false,
			capture=false,
			//bgcolor=0x123456, onloaded='tween(bgalpha,0.3,1.0);',	// optional: colorize the background
			ondown='popup_close()'
		);
			
		
		addlayer('popup', popup);
		set(popup,
			type=container,
			parent='popup_bg',
			width=calc(min(width,global.stagewidth*1)),
			height=calc(min(height,global.stageheight*1)),
			align=center,
			bgborder='1 0x555555 1',
			bgcolor=0x574e4b,
			bgalpha=0.7,
			bgshadow='0 10 20 0x000000 0.5',
			bgcapture=true,
			maskchildren=false,
			capture=true,
			handcursor=false,
			alpha=0
		);
		
		// optional: add a close button
		 addlayer('popup_close_x', closex);
		set(closex,
			//url='%VIEWER%/popups/closex.png',
			
// fer adapting
type=text,
html=CERRAR,
x.normal=60,
x.mobile=0,
y=0,
interactivecontent=true,
bgcolor=0x2D3E50,
bgalpha=0.8,
bgborder=0,
bgroundedge=1,
padding=5 5 5 5,
css=color:#FFFFFF; font-family:Arial;,
txtshadow=1,
bgshadow=0 4 10 0x000000 0.3,
//end de fer adapating

			parent='popup',
			align=righttop,
			//x=0,
			//y=0,
			edge=righttop,
			scale=0.3,
			zorder=99,
			alpha=0.7,
			onover='tween(alpha,1)',
			onout='tween(alpha,0.7)',
			onup='tween(alpha,0.7)',
			onclick='popup_close()'
		);

		if(type == 'html',
			set(popup.type, html);
			copy(popup.html, content);
			copy(popup.htmlscrollbars, scrollbars);

		  ,type == 'iframe',
			set(popup.type, iframe);
			copy(popup.iframeurl, content);

		  ,type == 'image',
		 	set(popup,
		 		bgcolor=0xFFFFFF,
		 		bgalpha=1,
		 	);
			addlayer("popup_image", img);
			set(img,
				url=get(content),
				align=center,
				width=-20, height=-20,
				parent=get(popup.name),
				onloaded='popup_imageloaded()'
			);
		);

		tween(global.plugin[pp_blur].range, 40.0);
		delayedcall(0.2, tween(global.layer[popup].alpha, 1.0); );

		// events when the popup should get closed automatically
		set(global.events[popup].onremovepano, popup_close() );
		set(global.events[popup].onresize, popup_close() );				
	
	]]></action>

This post has been edited 1 times, last edit by "Fernando" (Jan 30th 2023, 3:51pm)


4

Monday, January 30th 2023, 3:55pm

Hi,

this would be the correct syntax:

Source code

1
2
3
4
5
6
set(closex,
  type=text,
  html=CERRAR,
  x=calc(device.mobile ? 0 : 60),
  y=0,
  ...


The 'x.normal' and 'x.mobile' are xml-parsing filters - that means during loading/parsing the xml file, xml attributes that have a dot will get filtered depending on the condition after the dot - see also here:
https://krpano.com/docu/xml/#devicechecksforattributes

For dynamic/runtime code, an explicit device checking would be need, e.g. like an if() check or an expression with a Ternary operator (if ? then-value : else-value)

Best regards,
Klaus

Fernando

Intermediate

  • "Fernando" started this thread

Posts: 328

Location: Habana, Cuba

Occupation: Architect, Photographer.

  • Send private message

5

Monday, January 30th 2023, 8:33pm

It does not work yet with ternary operator...

Hi, Klaus, thanks for your answer. But does not work: (Line 8 of code)

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// optional: add a close button
		addlayer('popup_close_x', closex);
		set(closex,
			url='%CURRENTXML%/closex.png',
			parent='popup',
			align=righttop,
			edge=center,
x=calc(device.mobile ? 0 : 60),	
			scale=0.5,
			zorder=99,
			alpha=0.25,
			onover='tween(alpha,1)',
			onout='tween(alpha,0.25)',
			ondown='tween(alpha,1)',
			onup='tween(alpha,0.25)',
			onclick='popup_close()'
		);

I temporalily (only for this question) upload your example with the code you suggest, but in mobile device the close button is moved as in normal device (60 pixels to the left and not zero as it would correspond).
See in http://www.mirapanoramas.nat.cu/testing/docu/examples.html

This post has been edited 1 times, last edit by "Fernando" (Jan 30th 2023, 10:33pm)


6

Monday, January 30th 2023, 8:50pm

ups, sorry, i didn't see you were using set() .-)