📄 popuptest.xml
字号:
<?xml version="1.0"?><!-- Test app for popups. Try right clicking and ctrl+click as well as clicking and tabbing around--><Application> <Window caption="Popup" width="500" height="500"/> <Resources> <Script><![CDATA[function PopupTest() { var win = application.getWindow(); var b = new BiBorder(1, "solid", "ThreeDDarkShadow"); var p = new BiPopup("Hello World\nWith popup child"); p.setPadding(1); p.setName("popup1"); p.setSize(100, 40); p.setBackColor("Menu"); p.setBorder(b); win.add(p); var c = new BiComponent; c.setBackColor("ActiveCaption"); c.setLocation(200, 100); c.setSize(100, 100); win.add(c); var p2 = new BiPopup("Hello World 2\nFixed position relative to c"); p2.setPadding(1); p2.setName("popup2"); p2.setLocation(10, 10); p2.setSize(160, 40); p2.setBackColor("Menu"); p2.setBorder(b); c.add(p2); var p3 = new BiPopup("Inside popup\n(allowOffScreen)"); p3.setPadding(1); p3.setName("popup3"); p3.setAllowOffScreen(true); p3.setSize(100, 40); p3.setBackColor("Menu"); p3.setBorder(b); p.add(p3); var p4 = new BiPopup("Not auto hiding"); p4.setPadding(1); p4.setName("popup4"); p4.setAutoHide(false); p4.setLocation(160, 10); p4.setSize(100, 20); p4.setBackColor("Menu"); p4.setBorder(b); win.add(p4); var p5 = new BiPopup("Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component.\n" + "Relative to component."); p5.setWrap(true); p5.setPadding(1); p5.setName("popup5"); p5.positionRelativeToComponent(c, "horizontal"); //p5.setSize(100, 20); p5.setBackColor("Menu"); p5.setBorder(b); //p5.setPreferredWidth(200); //p5.setPreferredHeight(200); //p5.setAutoHide(false); //p5.setAllowOffScreen(true); win.add(p5); var b = new BiButton("Show (Also testes focus)"); b.setWidth(150); b.setLocation(5, 5); win.add(b); var b2 = new BiButton("Hide (Also testing focus)"); b2.setWidth(150); b2.setLocation(5, 35); win.add(b2); var out = new BiLabel; out.setTabIndex(2); out.setBorder(new BiBorder(1, "solid", "ThreeDDarkShadow")); out.setBackColor("window"); out.setOverflow("auto"); out.setPadding(2); out.setLocation(5, b2.getTop() + b2.getHeight() + 5); out.setSize(150, 200); win.add(out); this._outLabel = out; // event listeners // for showing the popups win.addEventListener("click", function (e) { if (e.getCtrlKey()) { p5.setVisible(true); return; } if (e.getTarget() == p) return; p.setScreenLeft(e.getScreenX() + 3); p.setScreenTop(e.getScreenY() + 3); p.setVisible(true); }); win.addEventListener("contextmenu", function (e) { if (p2.contains(e.getTarget())) return; //p2.setScreenLeft(e.getScreenX() + 3); //p2.setScreenTop(e.getScreenY() + 3); p2.setVisible(true); }); p.addEventListener("click", function (e) { e.stopPropagation(); // don't reposition p3 if clicked if (p3.contains(e.getTarget())) return; p3.setScreenLeft(e.getScreenX() + 3); p3.setScreenTop(e.getScreenY() + 3); p3.setVisible(true); }); // the button clicks b.addEventListener("click", function (e) { e.stopPropagation(); p4.setVisible(true); //alert(p4.getWidth()) }); b2.addEventListener("click", function (e) { e.stopPropagation(); p4.setVisible(false); }); // the show hide events p.addEventListener("show", this.onPopupShow, this); p.addEventListener("hide", this.onPopupHide, this); p2.addEventListener("show", this.onPopupShow, this); p2.addEventListener("hide", this.onPopupHide, this); p3.addEventListener("show", this.onPopupShow, this); p3.addEventListener("hide", this.onPopupHide, this); p4.addEventListener("show", this.onPopupShow, this); p4.addEventListener("hide", this.onPopupHide, this); p5.addEventListener("show", this.onPopupShow, this); p5.addEventListener("hide", this.onPopupHide, this);}PopupTest.prototype.onPopupShow = function (e) { this.print(e.getTarget().getName() + " shown");};PopupTest.prototype.onPopupHide = function (e) { this.print(e.getTarget().getName() + " hidden");};PopupTest.prototype.print = function (s) { this._outLabel.setHtml(this._outLabel.getHtml() + s + "<br>"); this._outLabel.setScrollTop(9999999);};PopupTest.main = function () { new PopupTest; }; ]]></Script> </Resources></Application>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -