TIScript 代码Demo
var filelist = null; function alert(msg) { view.msgbox(null,msg); } self.on("click", "menu > li ", function() { var button_value = this.value; if(button_value=="打开PDF") { filelist = view.onOpenPdf(); var mLen = filelist.length; for(var i=0; i < mLen; i++){ $(#left_preview_box).$append(<img id=list_{i} />); //$(img).attributes["src"] = "./image/ball.png"; //$(img).attributes["width"]="200px"; } for(var i=0; i < mLen; i++) { $(#list_{i}).attributes["src"] = filelist[i]; $(#list_{i}).attributes["width"] = "80px"; } } }); $(#left_preview_box).on("click","img",function(){ var m_id = this.attributes["id"].toString(); var m_no = m_id.substring(5,m_id.length).toInteger(); if(filelist) { $(#left_view_box>img).attributes["src"] = filelist[m_no]; $(#left_view_box>img).attributes["width"] = "100%"; } }); self.ready = function() { var start_x; var start_y; var end_x; var end_y; var is_move = false; var is_enter = false; var is_ctrl = false; var is_wheel = 0; var cur_x; var cur_y; $(#main_image).on("mousedown",function(event){ if(is_ctrl){ start_x = event.x; start_y = event.y; is_move = true; } }); //Ctrl+MouseLeft 移动图片 $(#main_image).on("mousemove",function(event){ cur_x = event.x; cur_y = event.y; if(is_move && is_ctrl) { end_x = event.x; end_y = event.y; var g_left = $(#main_image).style["left"].toString(); var n_left = g_left.substring(0,g_left.length-2).toInteger(); var g_top = $(#main_image).style["top"].toString(); var n_top = g_top.substring(0,g_top.length-2).toInteger(); var m_left = (n_left + end_x -start_x)+"px"; var m_top = (n_top + end_y -start_y)+"px"; $(#main_image).style["left"] = m_left; $(#main_image).style["top"] = m_top; } }); $(#main_image).on("mouseup",function(event){ var msg = (end_x-start_x)+","+(end_y-start_y); is_move = false; }); $(#main_image).on("mouseleave",function(event){ is_move = false; }); var idd = 0; function windowKeyHandler() // install movable window handler { function onKeyDown(evt) { if(evt.keyCode == Event.VK_CONTROL ) { is_ctrl = true; } } function onKeyUp(evt) { if(evt.keyCode == Event.VK_CONTROL ) { is_ctrl = false; } } function onWheelPos(evt){ } function onImageWheelPos(event){ is_wheel = event.wheelDelta; //放大 if(is_ctrl) { $(#left_view_box).style["overflow"]="hidden"; if(is_wheel == 1){ $(#main_image).style["background-size"] = "150%"; } else if(is_ctrl && is_wheel == -1){ $(#main_image).style["background-size"] = "50%"; } } else{ $(#left_view_box).style["overflow"]="scroll"; } } view.root.subscribe(onKeyDown, Event.KEY, Event.KEY_DOWN ); view.root.subscribe(onKeyUp, Event.KEY, Event.KEY_UP ); //view.root.subscribe(onWheelPos, Event.MOUSE, Event.MOUSE_WHEEL ); $(#main_image).subscribe(onImageWheelPos, Event.MOUSE, Event.MOUSE_WHEEL ); return true; } windowKeyHandler(); }
var ret = view.msgbox(#information, "这个函数将调用底层编写的函数", "你确定调用?",[ {id:#yes, text:"确定"}, {id:#no, text:"取消"} ] ); if( ret == #yes ) { stdout.println("确定"); // 一定要以view.xxxx(xx)方式调用 ret = view.addsome(3,2); }else{ stdout.println("取消"); }
function paint(gfx) { gfx.pushLayer(#background-area); gfx.strokeWidth(0.7); gfx.strokeColor(color(255,255,0)); for(var i=0;i<rectList.length;i++) { gfx.rectangle(rectList[i].x,rectList[i].y,rectList[i].w,rectList[i].h); } //gfx.popLayer(); gfx.save(); } $(#canvasAuto).paintContent = paint; $(#canvasAuto).refresh();
transition: height(quart-out,1.0s,quart-in);
设置滚动条的位置 $(#view_box).scrollTo(0,50); var p1 = $(#view_box).box(#height,#content); 获取该div内容的总高度 var p2 = $(#view_box).box(#height,#client); 获取该div可见高度