Skip to content

Commit 974d22f

Browse files
authored
Merge pull request #17 from defold/Issue-6-replace-uiwebview
Issue-6 Replace UIWebView with WKWebView
2 parents e3d2b8a + c681c76 commit 974d22f

File tree

7 files changed

+426
-46
lines changed

7 files changed

+426
-46
lines changed

main/main.gui

Lines changed: 325 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ background_color {
88
nodes {
99
position {
1010
x: 320.0
11-
y: 175.0
11+
y: 125.0
1212
z: 0.0
1313
w: 1.0
1414
}
@@ -169,7 +169,7 @@ nodes {
169169
nodes {
170170
position {
171171
x: 215.0
172-
y: 81.0
172+
y: 55.0
173173
z: 0.0
174174
w: 1.0
175175
}
@@ -330,7 +330,7 @@ nodes {
330330
nodes {
331331
position {
332332
x: 425.0
333-
y: 81.0
333+
y: 55.0
334334
z: 0.0
335335
w: 1.0
336336
}
@@ -488,6 +488,328 @@ nodes {
488488
text_leading: 1.0
489489
text_tracking: 0.0
490490
}
491+
nodes {
492+
position {
493+
x: 320.0
494+
y: 265.0
495+
z: 0.0
496+
w: 1.0
497+
}
498+
rotation {
499+
x: 0.0
500+
y: 0.0
501+
z: 0.0
502+
w: 1.0
503+
}
504+
scale {
505+
x: 0.5
506+
y: 0.5
507+
z: 1.0
508+
w: 1.0
509+
}
510+
size {
511+
x: 200.0
512+
y: 100.0
513+
z: 0.0
514+
w: 1.0
515+
}
516+
color {
517+
x: 1.0
518+
y: 1.0
519+
z: 1.0
520+
w: 1.0
521+
}
522+
type: TYPE_TEMPLATE
523+
id: "button_eval"
524+
layer: ""
525+
inherit_alpha: true
526+
alpha: 1.0
527+
template: "/dirtylarry/button.gui"
528+
template_node_child: false
529+
}
530+
nodes {
531+
position {
532+
x: 0.0
533+
y: 0.0
534+
z: 0.0
535+
w: 1.0
536+
}
537+
rotation {
538+
x: 0.0
539+
y: 0.0
540+
z: 0.0
541+
w: 1.0
542+
}
543+
scale {
544+
x: 1.0
545+
y: 1.0
546+
z: 1.0
547+
w: 1.0
548+
}
549+
size {
550+
x: 800.0
551+
y: 120.0
552+
z: 0.0
553+
w: 1.0
554+
}
555+
color {
556+
x: 1.0
557+
y: 1.0
558+
z: 1.0
559+
w: 1.0
560+
}
561+
type: TYPE_BOX
562+
blend_mode: BLEND_MODE_ALPHA
563+
texture: "button/button_normal"
564+
id: "button_eval/larrybutton"
565+
xanchor: XANCHOR_NONE
566+
yanchor: YANCHOR_NONE
567+
pivot: PIVOT_CENTER
568+
adjust_mode: ADJUST_MODE_FIT
569+
parent: "button_eval"
570+
layer: ""
571+
inherit_alpha: true
572+
slice9 {
573+
x: 32.0
574+
y: 32.0
575+
z: 32.0
576+
w: 32.0
577+
}
578+
clipping_mode: CLIPPING_MODE_NONE
579+
clipping_visible: true
580+
clipping_inverted: false
581+
alpha: 1.0
582+
overridden_fields: 4
583+
template_node_child: true
584+
size_mode: SIZE_MODE_MANUAL
585+
}
586+
nodes {
587+
position {
588+
x: 0.0
589+
y: 0.0
590+
z: 0.0
591+
w: 1.0
592+
}
593+
rotation {
594+
x: 0.0
595+
y: 0.0
596+
z: 0.0
597+
w: 1.0
598+
}
599+
scale {
600+
x: 1.5
601+
y: 1.5
602+
z: 1.0
603+
w: 1.0
604+
}
605+
size {
606+
x: 200.0
607+
y: 100.0
608+
z: 0.0
609+
w: 1.0
610+
}
611+
color {
612+
x: 1.0
613+
y: 1.0
614+
z: 1.0
615+
w: 1.0
616+
}
617+
type: TYPE_TEXT
618+
blend_mode: BLEND_MODE_ALPHA
619+
text: "Eval 1+1"
620+
font: "larryfont"
621+
id: "button_eval/larrylabel"
622+
xanchor: XANCHOR_NONE
623+
yanchor: YANCHOR_NONE
624+
pivot: PIVOT_CENTER
625+
outline {
626+
x: 0.0
627+
y: 0.0
628+
z: 0.0
629+
w: 1.0
630+
}
631+
shadow {
632+
x: 1.0
633+
y: 1.0
634+
z: 1.0
635+
w: 1.0
636+
}
637+
adjust_mode: ADJUST_MODE_FIT
638+
line_break: false
639+
parent: "button_eval/larrybutton"
640+
layer: ""
641+
inherit_alpha: true
642+
alpha: 1.0
643+
outline_alpha: 0.0
644+
shadow_alpha: 1.0
645+
overridden_fields: 3
646+
overridden_fields: 8
647+
overridden_fields: 31
648+
template_node_child: true
649+
text_leading: 1.0
650+
text_tracking: 0.0
651+
}
652+
nodes {
653+
position {
654+
x: 320.0
655+
y: 195.0
656+
z: 0.0
657+
w: 1.0
658+
}
659+
rotation {
660+
x: 0.0
661+
y: 0.0
662+
z: 0.0
663+
w: 1.0
664+
}
665+
scale {
666+
x: 0.5
667+
y: 0.5
668+
z: 1.0
669+
w: 1.0
670+
}
671+
size {
672+
x: 200.0
673+
y: 100.0
674+
z: 0.0
675+
w: 1.0
676+
}
677+
color {
678+
x: 1.0
679+
y: 1.0
680+
z: 1.0
681+
w: 1.0
682+
}
683+
type: TYPE_TEMPLATE
684+
id: "button_html"
685+
layer: ""
686+
inherit_alpha: true
687+
alpha: 1.0
688+
template: "/dirtylarry/button.gui"
689+
template_node_child: false
690+
}
691+
nodes {
692+
position {
693+
x: 0.0
694+
y: 0.0
695+
z: 0.0
696+
w: 1.0
697+
}
698+
rotation {
699+
x: 0.0
700+
y: 0.0
701+
z: 0.0
702+
w: 1.0
703+
}
704+
scale {
705+
x: 1.0
706+
y: 1.0
707+
z: 1.0
708+
w: 1.0
709+
}
710+
size {
711+
x: 800.0
712+
y: 120.0
713+
z: 0.0
714+
w: 1.0
715+
}
716+
color {
717+
x: 1.0
718+
y: 1.0
719+
z: 1.0
720+
w: 1.0
721+
}
722+
type: TYPE_BOX
723+
blend_mode: BLEND_MODE_ALPHA
724+
texture: "button/button_normal"
725+
id: "button_html/larrybutton"
726+
xanchor: XANCHOR_NONE
727+
yanchor: YANCHOR_NONE
728+
pivot: PIVOT_CENTER
729+
adjust_mode: ADJUST_MODE_FIT
730+
parent: "button_html"
731+
layer: ""
732+
inherit_alpha: true
733+
slice9 {
734+
x: 32.0
735+
y: 32.0
736+
z: 32.0
737+
w: 32.0
738+
}
739+
clipping_mode: CLIPPING_MODE_NONE
740+
clipping_visible: true
741+
clipping_inverted: false
742+
alpha: 1.0
743+
overridden_fields: 4
744+
template_node_child: true
745+
size_mode: SIZE_MODE_MANUAL
746+
}
747+
nodes {
748+
position {
749+
x: 0.0
750+
y: 0.0
751+
z: 0.0
752+
w: 1.0
753+
}
754+
rotation {
755+
x: 0.0
756+
y: 0.0
757+
z: 0.0
758+
w: 1.0
759+
}
760+
scale {
761+
x: 1.5
762+
y: 1.5
763+
z: 1.0
764+
w: 1.0
765+
}
766+
size {
767+
x: 200.0
768+
y: 100.0
769+
z: 0.0
770+
w: 1.0
771+
}
772+
color {
773+
x: 1.0
774+
y: 1.0
775+
z: 1.0
776+
w: 1.0
777+
}
778+
type: TYPE_TEXT
779+
blend_mode: BLEND_MODE_ALPHA
780+
text: "Open HTML"
781+
font: "larryfont"
782+
id: "button_html/larrylabel"
783+
xanchor: XANCHOR_NONE
784+
yanchor: YANCHOR_NONE
785+
pivot: PIVOT_CENTER
786+
outline {
787+
x: 0.0
788+
y: 0.0
789+
z: 0.0
790+
w: 1.0
791+
}
792+
shadow {
793+
x: 1.0
794+
y: 1.0
795+
z: 1.0
796+
w: 1.0
797+
}
798+
adjust_mode: ADJUST_MODE_FIT
799+
line_break: false
800+
parent: "button_html/larrybutton"
801+
layer: ""
802+
inherit_alpha: true
803+
alpha: 1.0
804+
outline_alpha: 0.0
805+
shadow_alpha: 1.0
806+
overridden_fields: 3
807+
overridden_fields: 8
808+
overridden_fields: 31
809+
template_node_child: true
810+
text_leading: 1.0
811+
text_tracking: 0.0
812+
}
491813
material: "/builtins/materials/gui.material"
492814
adjust_reference: ADJUST_REFERENCE_PARENT
493815
max_nodes: 512

main/main.gui_script

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
local dirtylarry = require("dirtylarry.dirtylarry")
22

3+
HTML = [[
4+
<html>
5+
<head>
6+
<title>Defold webview</title>
7+
</head>
8+
<body>
9+
Hello World
10+
</body>
11+
</html>
12+
]]
13+
14+
315
local function webview_callback(self, webview_id, request_id, type, data)
16+
print("webview_callback", webview_id, request_id)
417
if type == webview.CALLBACK_RESULT_URL_OK then
518
print("CALLBACK_RESULT_URL_OK")
619

@@ -66,6 +79,18 @@ function on_input(self, action_id, action)
6679
webview.open(self.webview_id, "https://www.google.com")
6780
end)
6881

82+
dirtylarry:button("button_eval", action_id, action, function()
83+
if not webview_available() then return end
84+
85+
webview.eval(self.webview_id, "1+1")
86+
end)
87+
88+
dirtylarry:button("button_html", action_id, action, function()
89+
if not webview_available() then return end
90+
91+
webview.open_raw(self.webview_id, HTML)
92+
end)
93+
6994
dirtylarry:button("button_show", action_id, action, function()
7095
if not webview_available() then return end
7196

0 commit comments

Comments
 (0)