Curl Global Community
独立型アプレットでのサブアプレット - Printable Version

+- Curl Global Community (https://communities.curl.com)
+-- Forum: Discussions (https://communities.curl.com/forumdisplay.php?fid=1)
+--- Forum: General Curl questions (https://communities.curl.com/forumdisplay.php?fid=2)
+--- Thread: 独立型アプレットでのサブアプレット (/showthread.php?tid=1180)



独立型アプレットでのサブアプレット - nitakanworld - 11-02-2014

はじめまして、Curlを勉強中です。

Webブラウザを使わないで動作する独立型アプレットでツールを作ろうと思っています。
バックグラウンドで定期的に処理を行いたいのですが、
サブアプレット用のクラスメソッドを上手く呼ぶことができません。
特にエラーもなく、何処が原因かわからないのでアドバイスお願いします。

参考にしたページは以下です。
http://developers.curlap.com/re-reference/19-others/62-backgroud.html
http://developers.curlap.com/curl/docs/caede/ja/docs/ja/dguide/javascript.html

独立型アプレットではサブアプレットは作れないのでしょうか・・・?



RE: 独立型アプレットでのサブアプレット - umemura - 11-07-2014

私の環境(Curl8.0)では、特に問題なく動き(Curlのコンソールに「child」と出力され)ました。

■parent.dcurl
Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}
}
{import * from CURL.ENGINE.BROWSER}
|| AppletData
{define-class public ChildAppletData {inherits AppletData}
  {constructor public {default
                          ag:#AppletGraphic,
                          u:Url
                      }
    {construct-super ag, u}
  }
}
{def child = {ChildAppletData null, {url "child.curl"}}}
{View
    || この{Frame}を置き換えて使用してください
    {Frame width = 8cm, height = 8cm

        ,{VBox
            spacing = 2pt

             ,{spaced-hbox
                 {CommandButton
                     label = "start",
                     {on Action do
                         {child.applet-invoke-async
                             finish-proc = {proc {ex:#Exception, result:any}:void},
                             "start"
                         }
                     }
                 },

                 {CommandButton
                     label = "stop",
                     {on Action do
                         {child.applet-invoke-async
                             finish-proc = {proc {ex:#Exception, result:any}:void},
                             "stop"
                         }
                     }
                 },

                 {CommandButton
                     label = "change string",
                     {on Action do
                         {child.applet-invoke-async
                             finish-proc =
                                 {proc {ex:#Exception, result:any}:void
                                     {if-non-null ex then
                                         {popup-message "Error! " & ex}
                                     }
                                 },
                             "change-displayed-string", "abc"
                         }
                     }
                 }
             }
        }
    },
    visibility = "normal",
    {on WindowClose do
        {exit}
    }
}


■child
Code:
{curl 8.0 applet}
{curl-file-attributes character-encoding = "utf8"}
{applet manifest = "manifest.mcurl",
    {compiler-directives careful? = true}
}


{define-class public Child

  field displayed-string:String
  field private timer:Timer

  {constructor public {default}
    set self.displayed-string = "child"
    set self.timer =
        {Timer
            enabled? = false,
            interval = 1s,
            {on TimerEvent do
                {output self.displayed-string}
            }
        }
  }

  {method public {start}:void
    {self.timer.enable}
  }

  {method public {change-displayed-string str:String}:void
    set self.displayed-string = str
  }

  {method public {stop}:void
    {self.timer.disable}
  }
}

{{get-the-applet}.register-applet-invoke-handler
    {Applet.applet-invoke-handler-for-object {Child}},
    verifier = {proc {}:bool {return true}}
}