Ah, calling act: on the tree, that makes sense.
2014-08-14 7:11 GMT+02:00 Tudor Girba <[email protected]>: > Hi, > > The important visual objects, such as the selection, are reflected on the > ports of the pane containing the presentation. > > The tree has two ports that are relevant for selection: > - #selection will give you the selected node > - #selectionPath will give you the path from the selected node to the root > > You can do like this: > a tree > act: [:treePresentation | treePresentation selection inspect ] > entitled: 'Inspect selection'; > act: [:treePresentation | treePresentation selectionPath inspect ] > entitled: 'Inspect selection path' > > > Cheers, > Doru > > > > On Thu, Aug 14, 2014 at 1:32 AM, Nicolai Hess <[email protected]> wrote: > >> Hi Offray, >> >> some notes about your code: >> >> >> browser >> act: [:newNode | >> newNode := UbakyeNode >> header: 'nuevoNodo' body: >> ''. >> mainTree addNode: newNode.] >> >> this would change the block parameter "newNode", but the block parameter >> is supposed to deliver the object you'll act on, the browser for example. >> I think you wanted to write this code: >> >> browser >> act: [ :b | |newNode| >> >> newNode := UbakyeNode >> header: 'nuevoNodo' body: ''. >> b entity addNode: newNode . >> >> if you call "b update" like you did in the "remove action" your browse >> tree update will work. >> >> changing OrderedCollection to GLMAnnouncingCollection should work, but >> you'll have to define >> the appropiate announcer source #children instead of #yourself. #yourself >> gives the mainTree, and that >> does not work as your mainTree is not a GLMAnnouncingCollection. >> >> updateOn: GLMItemAdded from: #children >> >> There are two things I don't understand >> >> 1. >> setting updateOn: on the browser does not work: >> >> browser updateOn: GLMItemAdded from: #children. >> >> but setting it on the tree >> >> (browser transmit) >> to: #preview; >> andShow: [ :a | >> a tree >> "-->" updateOn: GLMItemAdded from: #children; >> >> title: mainTree header; >> children: [:eachNode | eachNode children ]; >> >> format: [:eachNode | eachNode header ]. >> a text >> title: 'Text']. >> >> >> updates the tree when adding an element by the + button >> >> 2. is there a way to get the currently selected tree node? Otherwise >> all new nodes only added to the first node. >> >> >> There are plenty of examples, but no one with add/remove or selection on >> trees. >> >> >> Nicolai >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 2014-08-13 21:37 GMT+02:00 Offray Vladimir Luna Cárdenas < >> [email protected]>: >> >> Hi Usman, >>> >>> >>> On 08/13/2014 02:16 AM, Usman Bhatti wrote: >>> >>>> Hi Offray, >>>> >>>> As Doru mentioned, without a complete example it is difficult to >>>> reproduce and >>>> analyze your problem. >>>> >>> >>> My main issue is that I don't know how to share a complete example >>> except by sharing this url: >>> >>> http://smalltalkhub.com/#!/~Offray/Ubakye/ >>> >>> and advising to upload the code and run "UbakyeBrowser open". In file >>> based frameworks I can point to a specific file which contains the model >>> of my defined objects, but I don't know how to share my own defined >>> objects/messages in Smalltalk except by this or by manually cutting and >>> pasting to email (it should be a better way). >>> >>> Anyway this is the part where I define a UbakyeNode: >>> >>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >>> Object subclass: #UbakyeNode >>> instanceVariableNames: 'header headers key icon body children >>> parent node' >>> classVariableNames: '' >>> category: 'Ubakye-Model' >>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >>> >>> and the children method is the one which uses a colection: >>> >>> >>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >>> UbakyeNode>>children >>> "Returns the receivers list of children" >>> >>> ^ children ifNil: [children := OrderedCollection new] >>> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- >>> >>> >>> For the tree to get updated on node addition or removal, you need to use >>>> GLMAnnouncingCollection to group your nodes. Hence, when you add a new >>>> node in >>>> your announcing collection object, this code comes into effect: >>>> >>>> updateOn: GLMItemAdded from: #yourself; >>>> >>>> So, make sure you are using appropriate collection object. >>>> >>> >>> >>> I tried changing OrderedCollection in the children message by >>> GLMAnnouncingCollection, but the header message started to fail. Can I pass >>> my children collection to a GLMAnnouncingCollection just in the interface >>> or need I to change the object definition for the UbakyeNode, and if this >>> is the case, how can I access the header of a UbakyeNode stored in this >>> kind of collection? I know is kind of dumb to ask without proper context, >>> but I hope that the SmalltalkHub repository (or other method) can be used >>> to share my own defined object to make better questions. >>> >>> usman >>>> >>> >>> Cheers, >>> >>> Offray >>> >>> >>> >>> >> > > > -- > www.tudorgirba.com > > "Every thing has its own flow" >
