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 <off...@riseup.net> : > 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 > > > >