📄 dragtest2.xml
字号:
<Application> <Window caption="Test" width="400" height="300"> <SplitPane left="10" top="10" right="10" bottom="10" dividerLocation="200"> <Component id="c-1" backColor="window" border="1px solid threedshadow" overflow="auto"> <Image uri="images/exclamation.32.png"/> <Image uri="images/questionmark.48.png"/> <Image uri="images/stopmark.32.png"/> <Image uri="images/folder.open.32.png"/> <Image uri="images/infomark.16.png"/> <Image uri="images/views.16.png"/> <Label text="Hello"/> <Button text="Button"/> </Component> <Component id="c-2" backColor="window" border="1px solid threedshadow" overflow="auto"> <Image uri="images/exclamation.32.png"/> <Image uri="images/questionmark.48.png"/> <Image uri="images/stopmark.32.png"/> <Image uri="images/folder.open.32.png"/> <Image uri="images/infomark.16.png"/> <Label text="World"/> <CheckBox text="Check"/> <CheckBox text="Box"/> </Component> </SplitPane> </Window> <Resources> <Script><![CDATA[function DragTest2(){ var c1 = application.getComponentById( "c-1" ); var c2 = application.getComponentById( "c-2" ); doLayout( c1 ); doLayout( c2 ); // allow BiComponents to be dropped on the c1 and c2 c1.setDropDataTypes( ["bindows/component"] ); c2.setDropDataTypes( ["bindows/component"] ); var win = application.getWindow(); win.addEventListener( "dragstart", this.onDragStart, this ); win.addEventListener( "dragdrop", this.onDragDrop, this ); this.c1 = c1; this.c2 = c2;}_p = DragTest2.prototype;_p._className = "DragTest2";DragTest2.main = function (){ new DragTest2;};_p.onDragStart = function ( e ){ var t = e.getTarget(); if ( t.getParent() == this.c1 || t.getParent() == this.c2 ) { // listen to dragend so we can insert the component at the right place // in case of a cancel t.addEventListener( "dragend", this.onDragEnd, this ); // store parent and next sibling in case of cancel this._startContainer = t.getParent(); this._beforeItem = t.getNextSibling(); e.addData( "bindows/component", t ); e.addAction( "move" ); e.setDragIcon( t ) e.startDrag(); }};_p.onDragDrop = function ( e ){ // successful drop var t = e.getTarget(); var d = e.getData( "bindows/component" ); t.add( d ); doLayout( t ); doLayout( this._startContainer ); this._startContainer = null; this._beforeItem = null;};_p.onDragEnd = function ( e ){ var t = e.getTarget(); // drop canceled or failed if relatedTarget is null if ( this._startContainer && e.getRelatedTarget() == null ) { this._startContainer.add( t, this._beforeItem ); doLayout( this._startContainer ); this._startContainer = null; this._beforeItem = null; } t.removeEventListener( "dragend", this.onDragEnd, this );};function doLayout( c ){ var cs = c.getChildren(); var y = 2; for ( var i = 0; i < cs.length; i++ ) { cs[i].setLocation( 5, y ); y += cs[i].getPreferredHeight() + 2; }} ]]></Script> </Resources></Application>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -