web.view2 为风行者封装,请下载最新版本使用。
暂时还不是很完善,运行过程中偶尔会出现闪退现象。
运行效果:
示例代码:
import win.ui;
/*DSG{{*/
var winform = win.form(text="aardio form";right=800;bottom=500)
winform.add(
button={cls="button";text="取当前标题";left=450;top=0;right=530;bottom=40;dr=1;dt=1;z=5};
edit={cls="edit";text="http://chengxu.online";left=530;top=0;right=720;bottom=40;autohscroll=false;autovscroll=false;border=1;dr=1;dt=1;hidesel=1;z=3};
plus={cls="plus";left=10;top=0;right=120;bottom=40;align="left";bgcolor=15780518;dl=1;dt=1;notify=1;z=1};
plus2={cls="plus";left=130;top=0;right=240;bottom=40;align="left";bgcolor=15780518;dl=1;dt=1;notify=1;z=2};
plus3={cls="plus";text="打开网址";left=720;top=0;right=800;bottom=40;bgcolor=49230;dr=1;dt=1;notify=1;z=4}
)
/*}}*/
import web.view2
import win.ui.tabs
var tbs = win.ui.tabs(winform.plus,winform.plus2);
tbs.customIndex = 0;
tbs.clear();
tbs.itemMargin=1;
tbs.margin=400;
var cview;
tbs.oncommand = function(strip,id,event){
for(strip1 in tbs.each() ){
if strip1!=strip {
strip1.custom.show(false);
strip1.setForeground(null);
}
}
strip.custom.show(true);
strip.setForeground(0xFF8899FF);
cview = strip.webview;
winform.text = cview.getDocumentTitle();
}
tbs.beforeShowCloseButton = function(strip,rcStrip,rcCloseButton){
tbs.closeButton.oncommand = function( id,event ){
strip.custom.close();
tbs.deleteByStrip(strip)
owner.show(false);
if tbs.selStrip {
tbs.selStrip.custom.show(true);
tbs.selStrip.setForeground(0xFF8899FF);
cview = tbs.selStrip.webview;
winform.text = cview.getDocumentTitle();
} else {
cview = null;
winform.text = "";
}
}
return rcStrip.right-(rcCloseButton.right-rcCloseButton.left),rcStrip.top;
}
onNewWindow = function(url){
win.setTimeout(
function(){
tbs.customIndex++;
var index = tbs.customIndex;
var custom = "custom"++tbs.customIndex;
for(strip,form,idx in tbs.each() ){
strip.custom.show(false);
strip.setForeground(null);
}
winform.add(
[custom] = {
cls="custom";left=0;top=40;right=800;bottom=500;db=1;dl=1;dr=1;dt=1;z=0;
};
)
var neww = web.view2(winform[custom]);
if neww {
neww.go(url,false);
neww.wait("");
var idx = tbs.add({
text = neww.getDocumentTitle();
custom = winform[custom];
hasCloseButton=true;
foreground = 0xFF8899FF;
})
tbs.strips[idx].webview=neww;
cview = neww;
winform.text = cview.getDocumentTitle();
neww.onNewWindow = onNewWindow;
}
}
)
return true;
}
winform.plus3.oncommand = function(id,event){
if winform.edit.text="" return win.msgbox("请输入网址!");
onNewWindow(winform.edit.text)
}
onNewWindow("http://chengxu.online");
winform.button.oncommand = function(id,event){
..win.msgbox(cview?cview.getDocumentTitle():"未打开网页");
}
winform.show();
win.loopMessage();