I can set up one or more event listeners this way:
number roiListener1=imgDsp.ImageDisplayAddEventListener("roi_changed:ROI_Changed1")
number roiListener2=imgDsp.ImageDisplayAddEventListener("roi_changed:ROI_Changed2")
To remove them, I would do this:
imgDsp.ImageDisplayRemoveEventListener(roiListener1)
imgDsp.ImageDisplayRemoveEventListener(roiListener2)
Is there a way to remove all existing listeners attached on an imageDisplay, without giving the listener variable names?
Thanks,
Good question, but no, there isn't.
Except, of course, if the imageDisplay itself gets destroyed, which will remove the linked listeneres automatically, unless they themselves are "held" in memory due to something else (like a member-variable image which is displayed, another listener etc.)
The easiest way to "deal" with listeners is to manage the IDs in a TagList, then one can simply iterate over all entries.
Related
I want to check the list of event listeners that are added. For example, I used the code cy.on('pan zoom resize', update); and added function called update in for loop. I do this many times. I also call cy.off('pan zoom resize', update); to remove the event listeners but I want to be sure about it.
The only think I can think of is using console.log but this method might not be helpful.
I also think that in some places people forgot to remove the event listeners and just always added. With too many repetitions this might cause problems.
There is a data field in the private cytoscape object called listeners. You can see that if you:
console.log() the cy object,
navigate to _private,
then open the emitter object
and lastly go to listeners
This is the array listing all the default and user defined event listeners with some metadata like the event, type and scope of the listener.
You can access this in your code by simply calling
cy.emitter().listeners
The question now is, why do you need this information in the first place? Normally, you should be just fine if you call cy.off('eventXY', ...) before using any cy.on('eventXY', ...). Are you sure you need this for your application to work? Maybe elaborate more on the core problem (why you want these information in the first place).
Thanks and have a great day!
I have two columns that I would like to animate separately with a trigger. As I understand it: Skrollr only allows one instantiation on a page. Does anyone know if it's possible to have multiple instances that can be turned off and on?
I've started a working example here:
The grey column will activate the Skrollr instance when clicking on its "Activate!" button. (The "Destroy!" button will remove its instance.)
I would like to isolate the Skrollr animation to just the grey column, but as you can see in this example, the yellow/orange column is also being activated.
Three ways
Remove/add the data attributes between the destroy/init calls and only add them to the elements you want
Use two constants, defined as a function and toggle them between 0 and 1e6 (or something really large). Now the elements with the large one will effectively not be rendered (given you're using edgeStrategy reset)
Monkey patch the refresh method (without touching the skrollr code itself). Skrollr uses it internally when using init. Now you can patch it to use leftColumn.getElementsByTagName('*') or all elements in the right column when no parameter is passed. This way initializing will only affect elements inside one of the columns.
I have a user interface where some properties are represented as draggable items, and they can be dragged off a toolbar and dropped on some receiving item which is then updated. For this I'm using the Dojo Drag and Drop. I have some Dojo Dnd Sources, Targets, several accept types, everything is working great.
Except that I don't want to actually move or copy the nodes of the sources to the targets. When the drop occurs I simply want to fire an event handler so I can modify the target in question, or make other updates in the UI as appropriate.
What is the best way to do this?
I've tried variations on a null creator function, calling cancel in an onDrop handler, removing the nodes that are passed to the onDrop handler from their parent, but none of these avenues seemed to work or be workable.
Thanks for any assistance.
I just wrote this code which does what you want. (Though it seems you've tried something similar that didn't work?)
// Gobble up dropped nodes
target.on(
"Drop",
lang.hitch(
target,
function( source, nodes, copy )
{
this.selectAll().deleteSelectedNodes();
}
)
);
I just have a query on deleting displayobject instance. Let me elaborate on this:
I had created a custom component called ‘PanelItem’ (which basically contains a Text Area and a close button in a Panel container)
Then in the main.mxml, I had utilized the above custom component as follows:
var tempPanel: PanelItem = new PanelItem();
Subsequently assigned values for its attributes such as x,y, width, height and id for tempPanel and then added child instances as below
addChild(tempPanel);
The above code displays one instance of the custom displayobject. My problem is that when the ‘close’ button on the panel is clicked, I want the displayobject instance to be removed from the memory.
To do the ‘close’ action, I had added the following to the code
tempPanel.removAllChildren();
tempPanel.visible = false;
But the above only removes the children of displayobject and the doesnot removes the displayobject instance completely from memory. I read somewhere I need to ‘delete’ the displayobject, but could not find any reference to the same in the help file
Any thoughts on how do I go about removing the displayobject completely from memory?
Anther question I have is, if I had invoked multiple instances of tempPanel, how do I get a count of the number of instances.
TempPanel.numChildren() only returns the number of child instance (which got invoked thru addChild method) and not the actual numbers of displayobjects floating around.
Any help on the above will be much appreciated.
Thanks
Srinivasan S
you could extend from CasaSprite (http://as3.casalib.org/docs/org_casalib_display_CasaSprite.html) which has a destroy function.
I have a question with Value Converters, I have an array w/c filters inactive item, when I am editing an item and change the status property to 'INACTV', the table does not change. but when adding/removing items in the array, it refreshes, my workaround is creating a binded _signal property to force the filtering, is there a way not to do this?
< tr repeat.for="item of ARRAY | filtercustom:'STATUS_CD':'INACTV':_signal" >
I'm not sure I understood how the filter is supposed to work. But if it should hide inactive items, maybe you could do something like
<tr repeat.for="item of ARRAY" if.bind="!item.STATUS_CD='INACTV'">
I don't know if it is possible to put a value converter inside a "repeat.for". Looks weird.
I hope this helps to push you in the right direction.
No, there is no direct, clean way to do this at the moment. Repeat.for uses a CollectionObserver for array observation which only responds to pop/push/reverse/shift/sort/splice/unshift.
Only when one of these methods is called on the array, the observer fires and the array is fed to your ValueConverter again.
Your signal solution is about as clean as it gets. It's more efficient than the alternative of refreshing the whole array from manually instantiated property observers on your STATUS_CD property on every item in the array.
Which is what I do in some similar situations, because I don't like using signals. But that's just a matter of preference.