• R/O
  • SSH

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Haxe bindings for koreader


Commit MetaInfo

修訂136d1542ceb50887873b813bc5fc4d7d559d7381 (tree)
時間2021-03-22 07:51:52
作者Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@fast...>
CommiterJaime Marquínez Ferrándiz

Log Message

Reuse code from the plugin

Change Summary

差異

diff -r a5300699292f -r 136d1542ceb5 demo/Main.hx
--- a/demo/Main.hx Sun Mar 21 23:18:44 2021 +0100
+++ b/demo/Main.hx Sun Mar 21 23:51:52 2021 +0100
@@ -1,3 +1,4 @@
1+import haxeplug.HaxePlugin;
12 import koreader.ui.widget.container.FrameContainer;
23 import koreader.ui.widget.container.MovableContainer;
34 import koreader.ui.widget.container.CenterContainer;
@@ -5,8 +6,6 @@
56 import koreader.ui.widget.Button;
67 import koreader.ui.widget.HorizontalGroup;
78 import koreader.ui.UIManager;
8-import koreader.ui.widget.InfoMessage;
9-import koreader.ui.widget.ConfirmBox;
109 import koreader.Device;
1110 import koreader.Logger;
1211
@@ -15,28 +14,11 @@
1514 trace("Haxe trace");
1615 Logger.instance.dbg("Debug information:", 1);
1716
18- var confirm = ConfirmBox.create({
19- text: "Confirm box from Haxe",
20- ok_text: "OK text",
21- cancel_text: "Cancel text",
22- // ok_callback: blah,
23- ok_callback: function ok() {
24- var message = InfoMessage.create({text: "Accepted"});
25- UIManager.show(message);
26- },
27- cancel_callback: function cancel() {
28- var message = InfoMessage.create({text: "Canceled"});
29- UIManager.show(message);
30- },
31- });
32-
3317 var grp = HorizontalGroup.create({
3418 widgets: [
3519 Button.create({
3620 text: "Left",
37- callback: function left() {
38- UIManager.show(confirm);
39- }
21+ callback: HaxePlugin.displayWindow,
4022 }),
4123 VerticalGroup.create({
4224 widgets: [
diff -r a5300699292f -r 136d1542ceb5 demo/haxeplug/HaxePlugin.hx
--- a/demo/haxeplug/HaxePlugin.hx Sun Mar 21 23:18:44 2021 +0100
+++ b/demo/haxeplug/HaxePlugin.hx Sun Mar 21 23:51:52 2021 +0100
@@ -11,23 +11,25 @@
1111 override function addToMainMenu(menu_items : Dynamic) {
1212 Plugin.registerTool(menu_items, "hxplugDemo", {
1313 text: "Demo haxe plugin",
14- callback: function hxplug() {
15- var confirm = ConfirmBox.create({
16- text: "Confirm box from Haxe plugin",
17- ok_text: "OK text",
18- cancel_text: "Cancel text",
19- ok_callback: function ok() {
20- var response = HttpHelper.request("https://worldtimeapi.org/api/ip.txt");
21- var message = InfoMessage.create({text: "Accepted\n" + response});
22- UIManager.show(message);
23- },
24- cancel_callback: function cancel() {
25- var message = InfoMessage.create({text: "Canceled"});
26- UIManager.show(message);
27- },
28- });
29- UIManager.show(confirm);
14+ callback: displayWindow,
15+ });
16+ }
17+
18+ public static function displayWindow() {
19+ var confirm = ConfirmBox.create({
20+ text: "Confirm box from Haxe plugin",
21+ ok_text: "OK text",
22+ cancel_text: "Cancel text",
23+ ok_callback: function ok() {
24+ var response = HttpHelper.request("https://worldtimeapi.org/api/ip.txt");
25+ var message = InfoMessage.create({text: "Accepted\n" + response});
26+ UIManager.show(message);
27+ },
28+ cancel_callback: function cancel() {
29+ var message = InfoMessage.create({text: "Canceled"});
30+ UIManager.show(message);
3031 },
3132 });
33+ UIManager.show(confirm);
3234 }
3335 }
\ No newline at end of file