| 
			|  | マクロライブラリにアップした
 HmSplitTextFileByLine, HmSplitTextFileBySize,
 HmSplitTextFileByRegex(←おそらく月曜か火曜に表示されるんであろう)
 
 で制作している際に気づいたのですが、
 「レンダリング枠」と「getFunctionId」を初めてまともに使用してみたのですが、
 恐らく getFunctionId はバグっています。
 (避けられないバグというわけではないです)
 
 おそらく 「jsmodeの登場時」に「既存のものと同じjsmode空間名」が登場すると、
 その空間名にぶら下がった funcidがクリアされ、実態が見えなくなるんだろうと思
 います。
 
 
 ■再現ソース
 
 ---- test.mac------
 
 hidemaruversion "9.25.99";
 
 
 jsmode "WebView2";
 
 js {
 debuginfo(2);
 console.log(hidemaru.getJsMode());
 
 if (typeof (idInterval_MyUITemplate) != "undefined") {
 console.log("クリア");
 hidemaru.clearInterval(idInterval_MyUITemplate);
 }
 
 class MyUITemplate { // ここのクラス名はマクロファイル名ごとに書き換える
 
 constructor() {
 debuginfo(2);
 
 MyUITemplate.strTargetLabel = "RenderInputHtml";
 MyUITemplate.openRenderPane();
 }
 
 static outputAlert(err) {
 let dll = loaddll("HmOutputPane.dll");
 dll.dllFunc.Output(hidemaru.getCurrentWindowHandle(), err + "\r\n");
 }
 
 static openRenderPane() {
 let absoluteUrl = new URL(currentmacrodirectory() + "\\" + "RenderIn
 put.html");
 let idCallBack = hidemaru.getFunctionId(MyUITemplate.onHtmlButtonCli
 ck);
 console.log(idCallBack + "\r\n");
 let params = {
 strIDCallBack: idCallBack,
 };
 absoluteUrl.search = new URLSearchParams(params).toString();
 
 console.log(absoluteUrl.href);
 
 const json_arg = {
 target: MyUITemplate.strTargetLabel,
 uri: absoluteUrl,
 show: 1,
 place: "leftside",
 };
 
 renderpanecommand(json_arg);
 }
 
 static checkComplete() {
 console.log("checkComplete");
 try {
 let readyState = renderpanecommand({ target: "RenderInputHtml", get:
 "readyState" });
 if (readyState == "complete") {
 hidemaru.clearInterval(idInterval_MyUITemplate);
 console.log("complete");
 MyUITemplate.onRenderPaneShown();
 }
 } catch(err) {
 MyUITemplate.outputAlert(err);
 }
 }
 
 static onRenderPaneShown() {
 console.log("onRenderPaneShown");
 try {
 /*
 renderpanecommand({
 target: "RenderInputHtml",
 focus: 1,
 });
 */
 } catch(err) {
 MyUITemplate.outputAlert(err);
 }
 }
 
 static onHtmlButtonClick(json) {
 try {
 console.log("OK3");
 console.log(idInterval_MyUITemplate);
 hidemaru.clearInterval(idInterval_MyUITemplate);
 renderpanecommand({
 target: "RenderInputHtml",
 show: 0,
 });
 console.log("OK4");
 console.log("OK5");
 let strInputJson = json;
 console.log(json);
 hidemaru.postExecMacroMemory( "js {onPostExecute()}" );
 } catch(err) {
 MyUITemplate.outputAlert(err);
 }
 }
 
 
 
 }
 
 
 
 try {
 idInterval_MyUITemplate = hidemaru.setInterval(MyUITemplate.checkComplet
 e, 300);
 var myUITemplate = new MyUITemplate(); // let ではなく寿命が残るvarであ
 る必要がある。
 } catch(err) {
 }
 
 } // js
 
 
 jsmode "WebView2";
 
 js {
 debuginfo(2);
 console.log(hidemaru.getJsMode());
 
 function onPostExecute() {
 console.log("OK6");
 }
 }
 
 //-----------------------------------------
 
 
 ■再現リソース
 
 ---- RenderInput.html------
 
 <!DOCTYPE html>
 <html>
 
 <head>
 <title>ボタンクリックサンプル</title>
 </head>
 
 <body>
 1番目のパラメータ:<br>
  <input type="text" id="input_1"><br>
 <br>
 2番目のパラメータ:<br>
  <input type="text" id="input_2"><br>
 <br>
  <button id="button_1">OK</button><br>
 
 <script>
 // ボタンを取得
 const btn_1 = document.getElementById("button_1");
 // window.alert(btn_1);
 
 let idCallback = 0;
 // 現在のURLを取得
 var url = new URL(window.location.href);
 // パラメータを取得
 var params = new URLSearchParams(url.search);
 let strIDCallBack = params.get('strIDCallBack');
 idCallback = Number(strIDCallBack);
 
 // window.alert(idCallback);
 try {
 // window.alert("OK");
 // ボタンがクリックされた時の処理
 btn_1.addEventListener("click", function () {
 window.alert(idCallback);
 let message_obj = {
 input_1: input_1.value,
 input_2: input_2.value,
 };
 let json = JSON.stringify(message_obj);
 window.alert(json);
 window.chrome.webview.postMessage({ funcid: idCallback, mess
 age: json });
 });
 }
 catch (err) {
 // window.alert(err);
 }
 </script>
 </body>
 
 </html>
 
 //-----------------------------------------
 
 
 test.mac 実行し、レンダリングパネルのボタンを押しても、
 
 onHtmlButtonClick は実行されないことがわかります。
 (HTMLのjavascriptまでは実行されるが、funcidなどが渡っていても、postMessageを
 受け付けたあと、肝心のwebview2内の関数が実行されない)
 
 
 一度、秀丸上の全てのファイルを閉じて、 改めて、 test.macを開き、
 以下のように編集します。
 
 test.macの一番下の部分
 
 // ------------------------------
 
 /* 2回目のjsmodeをコメントアウトする
 jsmode "WebView2";
 
 js {
 debuginfo(2);
 console.log(hidemaru.getJsMode());
 
 function onPostExecute() {
 console.log("OK6");
 }
 }
 */
 
 // ------------------------------------
 
 
 なんとなんど、今度はちゃんと 実行されます。(-o-;) !!!!
 
 
 以上のことにより、同じ「jsmode空間」の宣言のタイミングで
 getFunctionId が正しくないのだと思います。
 (実際には getFunctionId そのものがバグってるのではなく、
 この関数が返す番号の元となる登録管理情報が jsmode 登場時に何か変わってる)
 
 
 | 
 |