On 2011-07-13, at 06:55, Raju Bitter wrote: > When I make a call to view.getDisplayObject() in the DHTML and mobile > runtime, the call returns the LzSprite.__LZdiv object. Is that the > expected behavior, or should it not return the view.sprite instance? > > Given the following code: > <canvas debug="true"> > > <view name="y1" x="200" y="10" width="100" height="100" bgcolor="yellow"> > > </view> > > <button text="y1.getDisplayObject()" onclick="Debug.info( > y1.getDisplayObject() )" /> > <button y="30" text="y1.sprite" onclick="Debug.info( y1.sprite )" /> > > </canvas> > > Debug.info( y1.getDisplayObject() ) gives me: > INFO: «HTMLDivElement#0| > #y1/@sprite/@__LZdiv/div.lzdiv[@style="background-color: rgb(255, 255, > 0); height: 100px; width: 100px; left: 200px; top: 10px; z-index: > 4;"]»
I should explain how to read this psuedo-xpath/css syntax (invented by Oliver). #y1 means y1 is a global (like an id, like # in css) @sprite means sprite is an attribute of y1 @__LZdiv ditto div.lzdiv says this is an HTML div element with class lzdiv [@style=...] describes the local css bindings on this element > And Debug.info( y1.sprite ) gives me: > INFO: «LzSprite#3| #y1/@sprite [100 x 100]*[1 0 200, 0 1 10, 0 0 1]» LzSprite is the kernel object that has different implementations for different platforms that implement the kernel API the generic OL code talks to > Here are my questions: > 1) What is the additional div __LZdiv used for? That is the actual platform-specific HTML element that implements the sprite in DHTML > 2) If I want to add HTML objects created through JavaScript to a view, > should I attach them to the sprite, or to the __LZdiv instance? The __LZdiv. That is the platform 'displayObject'. The sprite is not the actual display object. Bottom line: getDisplayObject is giving you the element where you can attach custom HTML or directly manipulate the platform object representing the sprite (at your own risk, of course).
