# HG changeset patch # User Claus Gittinger # Date 1571320067 -7200 # Node ID a28f8340a3eb0d3090109b398a6484df92f272c4 # Parent fac47345f7ba51005f6fa28a9e72f06dbbaa243b #UI_ENHANCEMENT by exept class: ShowMeHowItWorks class definition added: #drag:toComponent:dropAt:show: changed: #do: #do:from: #drag:toComponent:dropAt: diff -r fac47345f7ba -r a28f8340a3eb ShowMeHowItWorks.st --- a/ShowMeHowItWorks.st Wed Oct 16 16:12:22 2019 +0200 +++ b/ShowMeHowItWorks.st Thu Oct 17 15:47:47 2019 +0200 @@ -8,7 +8,7 @@ instanceVariableNames:'application opStream streamStack lastComponentName lastComponent lastResult voice translate language verifying closeApplicationWhenFinished defaultComponentWaitTime ui' - classVariableNames:'IntroShownCount DebugMode' + classVariableNames:'IntroShownCount DebugMode StartLabel' poolDictionaries:'' category:'Interface-Help' ! @@ -447,10 +447,21 @@ + self drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:nil +! + +drag:itemsIndexOrLabelOrPattern toComponent:targetComponentName dropAt:where show:textWhenDroppingOrNil + "drag an item (by index or label) from the current treeView, + into another component. + where is one of: #top, #center or #bottom. + allowed after moving to: + aSelectionInHierarchyView + " + + + |sourceComponent targetComponent idx yPos sourcePos sourcePosOnScreen - targetPos targetPosOnScreen targetPosInSource| - - self assert:( #(top center bottom) includes:where). + targetPos targetPosOnScreen targetPosInSource dNdMgr| verifying ifTrue:[^ self]. @@ -461,18 +472,29 @@ sourceComponent := sourceComponent scrolledView. ]. - (sourceComponent isKindOf:HierarchicalListView) ifTrue:[ - where == #top ifTrue:[ - targetPos := targetComponent topCenter. + where == #topLeft ifTrue:[ + targetPos := targetComponent topLeft + (1@1). + ] ifFalse:[ + where == #topCenter ifTrue:[ + targetPos := targetComponent topCenter + (0@1). ] ifFalse:[ where == #center ifTrue:[ targetPos := targetComponent center ] ifFalse:[ - where == #bottom ifTrue:[ + where == #bottomCenter ifTrue:[ targetPos := targetComponent bottomCenter - (0 @ 1) + ] ifFalse:[ + where == #bottomLeft ifTrue:[ + targetPos := targetComponent bottomLeft + (1 @ -1) + ] ifFalse:[ + self error:'where is this' + ]. ]. ]. ]. + ]. + + (sourceComponent isKindOf:HierarchicalListView) ifTrue:[ itemsIndexOrLabelOrPattern isInteger ifTrue:[ idx := itemsIndexOrLabelOrPattern @@ -496,22 +518,19 @@ targetPosInSource := Display translatePoint:targetPosOnScreen from:nil to:sourceComponent. sourceComponent simulateButtonPress:1 at:sourcePos sendDisplayEvent:true. - Delay waitForSeconds:0.5. + dNdMgr := sourceComponent startDragAt:sourcePos. + + textWhenDroppingOrNil notNil ifTrue:[ + self show:textWhenDroppingOrNil. + ]. + + Delay waitForSeconds:1. self movePointerToComponent:targetComponent offset:targetPos. - sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false. - sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:false. -self halt. - sourceComponent simulateButtonMotion:1 to:targetPosInSource sendDisplayEvent:false. - Delay waitForSeconds:0.5. - sourceComponent simulateButtonRelease:1 at:targetPosInSource sendDisplayEvent:true. + Delay waitForSeconds:1. + dNdMgr buttonMotion:1 x:targetPos x y:targetPos y view:targetComponent. -"/ self movePointerToComponent:targetComponent offset:targetPos. -"/ Delay waitForSeconds:2. -"/ self press:1. -"/ Delay waitForSeconds:2. -"/ self release:1. -"/ Delay waitForSeconds:0.5. - self halt. + sourceComponent simulateButtonRelease:1 at:targetPos sendDisplayEvent:true. + dNdMgr buttonRelease:1 x:targetPos x y:targetPos y view:targetComponent. ^ self ]. @@ -1479,10 +1498,10 @@ "must run as a separate process; otherwise - if started by the app itself - no events will be processed while running" - |startLabel| - startLabel := 'start'. - self do:specArray from:startLabel + "/ StartLabel := nil. + "/ StartLabel := 'start'. + self do:specArray from:StartLabel " @@ -1583,22 +1602,24 @@ otherwise - if started by the app itself - no events will be processed while running" - |wasActive| + |wasFlyByActive| - (wasActive := ActiveHelp isActive) ifTrue:[ - ActiveHelp stop. + (wasFlyByActive := FlyByHelp isSuspended) ifFalse:[ + FlyByHelp suspend. ]. + self prepare. "/ run once in verifying mode [ self verify:specArray. ] ensure:[ - wasActive ifTrue:[ActiveHelp start]. + wasFlyByActive ifTrue:[FlyByHelp resume]. ]. [ - ActiveHelp stop. + FlyByHelp suspend. + [ Error handle:[:ex | Dialog warn:(self class classResources @@ -1608,7 +1629,7 @@ self doStream:(specArray readStream) from:startLabelOrNil ]. ] ensure:[ - wasActive ifTrue:[ActiveHelp start]. + wasFlyByActive ifTrue:[FlyByHelp resume]. ]. ] fork.