ShowMeHowItWorks.st
changeset 3814 b57cff575911
parent 3804 2355596aec0a
child 3815 d9b849d3e63f
equal deleted inserted replaced
3813:04c48e162a22 3814:b57cff575911
  1004         ].
  1004         ].
  1005     ].
  1005     ].
  1006 
  1006 
  1007     (component isKindOf:NoteBookView) ifTrue:[
  1007     (component isKindOf:NoteBookView) ifTrue:[
  1008         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
  1008         (idx := itemsIndexOrLabelOrPattern) isInteger ifFalse:[
  1009             idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
  1009             idx := component list
       
  1010                     findFirst:[:eachNotebookTab| 
       
  1011                         eachNotebookTab label string = itemsIndexOrLabelOrPattern string
       
  1012                         or:[ eachNotebookTab printableLabel string = itemsIndexOrLabelOrPattern string ]
       
  1013                     ].
       
  1014             "/ idx := component indexOfTabNamed:itemsIndexOrLabelOrPattern
  1010         ].
  1015         ].
  1011         tab := component tabAtIndex:idx.
  1016         tab := component tabAtIndex:idx.
  1012         self movePointerToComponent:component offset:(tab layout center).
  1017         self movePointerToComponent:component offset:(tab layout center).
  1013         component selection:idx.
  1018         component selection:idx.
  1014         ^ self
  1019         ^ self
  1452             ^ self findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem item submenu
  1457             ^ self findComponent:componentNameOrPath in:anApplicationOrViewOrMenuItem item submenu
  1453         ].
  1458         ].
  1454     ].
  1459     ].
  1455 
  1460 
  1456     (componentNameOrPath startsWith:'item[') ifTrue:[
  1461     (componentNameOrPath startsWith:'item[') ifTrue:[
  1457         anApplicationOrViewOrMenuItem isMenu ifFalse:[
       
  1458             self assert:false message:'container is not a menu'.
       
  1459         ].
       
  1460         idxString := (componentNameOrPath withoutPrefix:'item[') withoutSuffix:']'.
  1462         idxString := (componentNameOrPath withoutPrefix:'item[') withoutSuffix:']'.
  1461         (idxString conform:#isDigit) ifTrue:[
  1463         (idxString conform:#isDigit) ifTrue:[
  1462             idx := Integer readFrom:idxString.
  1464             idx := Integer readFrom:idxString.
  1463             item := anApplicationOrViewOrMenuItem itemAtIndex:idx.
       
  1464         ] ifFalse:[
  1465         ] ifFalse:[
  1465             idxString := idxString withoutQuotes.
  1466             idxString := idxString withoutQuotes.
  1466             idxString includesMatchCharacters ifTrue:[
  1467             idx := nil.
  1467                 item := 
  1468         ].
  1468                     anApplicationOrViewOrMenuItem itemForWhich:[:item |
  1469 
  1469                         (idxString match:(item nameKey ? '') )
  1470         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifTrue:[
  1470                         or:[ (idxString match:(item textLabel ? '')) 
  1471             idx isNil ifTrue:[
  1471                         or:[ (item value isSymbol and:[idxString match:(item value)])]]
  1472                 idxString includesMatchCharacters ifTrue:[
  1472                     ]  
  1473                     idx := anApplicationOrViewOrMenuItem list 
       
  1474                                 findFirst:[:aTab| (aTab label matches:idxString)
       
  1475                                                     or:[aTab printableLabel matches:idxString]].
       
  1476                 ] ifFalse:[
       
  1477                     idx := anApplicationOrViewOrMenuItem listIndexOf:idxString
       
  1478                 ].
       
  1479             ].
       
  1480             idx notNil ifTrue:[
       
  1481                 self halt.
       
  1482             ]
       
  1483         ] ifFalse:[
       
  1484             anApplicationOrViewOrMenuItem isMenu ifFalse:[
       
  1485                 self assert:false message:'container is not a menu'.
       
  1486             ].
       
  1487             "/ a menu item
       
  1488             idx notNil ifTrue:[
       
  1489                 item := anApplicationOrViewOrMenuItem itemAtIndex:idx.
  1473             ] ifFalse:[
  1490             ] ifFalse:[
  1474                 item := 
  1491                 idxString includesMatchCharacters ifTrue:[
  1475                     anApplicationOrViewOrMenuItem itemForWhich:[:item |
  1492                     item := 
  1476                         item nameKey = idxString
  1493                         anApplicationOrViewOrMenuItem itemForWhich:[:item |
  1477                         or:[ item textLabel = idxString 
  1494                             (idxString match:(item nameKey ? '') )
  1478                         or:[ (item value isSymbol and:[ item value = idxString ])]]
  1495                             or:[ (idxString match:(item textLabel ? '')) 
  1479                     ]
  1496                             or:[ (item value isSymbol and:[idxString match:(item value)])]]
  1480             ].
  1497                         ]  
  1481         ].
  1498                 ] ifFalse:[
  1482         self assert:item notNil message:('no menu item named "%1"' bindWith:idxString).
  1499                     item := 
  1483         ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
  1500                         anApplicationOrViewOrMenuItem itemForWhich:[:item |
       
  1501                             item nameKey = idxString
       
  1502                             or:[ item textLabel = idxString 
       
  1503                             or:[ (item value isSymbol and:[ item value = idxString ])]]
       
  1504                         ]
       
  1505                 ].
       
  1506             ].
       
  1507             self assert:item notNil message:('no menu item named "%1"' bindWith:idxString).
       
  1508             ^ ItemInView new view:anApplicationOrViewOrMenuItem item:item boundsInView:(item layout)
       
  1509         ].
  1484     ].
  1510     ].
  1485     (componentNameOrPath startsWith:'tab[') ifTrue:[
  1511     (componentNameOrPath startsWith:'tab[') ifTrue:[
  1486         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifFalse:[
  1512         (anApplicationOrViewOrMenuItem isKindOf:NoteBookView) ifFalse:[
  1487             self assert:false message:'container is not a notebook'.
  1513             self assert:false message:'container is not a notebook'.
  1488         ].
  1514         ].