How to trigger an event as soon as we launch the view in SWT - swt

I have an RCP application where I am creating a view which invokes an instance of the composite.Now my problem is I want to trigger one event as soon as I show the view/composite in the screen.
I tried with addFocusListner(),addMouseTrackListener(),addMouseListner()but unfortunately none of the them gets the control as I move my mouse pointer around the view.Is there any way we can solve it?

Just grab the control you have used to create view and add selection listener on it.
for example if treeViewer is used to create that view then:
treeViewer.setSelection(new StructuredSelection(element),true);
Ensure selection by this treeViewer.getControl.setFocus();

If you want to trigger an event after your view is in focus/launch then you should add a listener to that view e.g IPartListener2for that you need to create a class and implement IPartListener2 interface. you will get more information here
Also if you want only using mouse event then you need to add MouseMoveListener to your view so when mouse pointer on your when mouseMove will call.
e.g. control.addMouseMoveListener(this);

Related

How can I make use of Event Delegation in a parent Svelte Component

In this example, if I click the Tutorial NavItem I get to the Tutorial
section. Here I forward an custom click event on every Nav Item, where I set the segment which has been clicked. In the app.svelte I pull in the NavItem component and set the segment to current, which tells the Nav Component (through Props), which segment is current and needs to be active.
My question is how Can i Make use of event Delegation, so the Nav Component listen for the click Event, so it doesn't feel so repetitiv
The minimal Example goes like that, I want the parent to handle the event?:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
Here is a complex Ex. the Repl:
https://svelte.dev/repl/691e82ee168549c782b61c355e78cf9b?version=3.12.1
I see you already use the getContext and setContext functionality. Instead of firing the event you can simply update that context:
in NavItem.svelte
function setSegment(){
current.set(segment);
}

how to bind OnClick event to Singleton function?

I want to bind OnClick event of UI Button to a function in Singleton object. I tried to do that, but every time I go to other scene and get back to the old scene I find that object disappear from the onClick field in the inspector while it's exist in the hierarchy ! If it's not possible to do that, what's the alternative way ?
Note: I'm using c#
Looks like this guy had a similiar problem: http://answers.unity3d.com/questions/335736/gameobject-still-destroyed-after-reloading-level.html
I would have posted this as a comment if I had enough reputation..

Best way to update view from command or filedialog in an eclipse rcp application

In my application I have a menu which open a SelectionDialog, this dialog is used to choose an object.
When this object is selected I have to display it in the view.
What is the best way to update my view?
Currently, I call myview.update(object) after the dialog is closed (in the handler of the menu). But I think this solution is not well design.
I have read about update my model and notify my view but my model does not change (no data are changed, I only display different Data ).
Does anyone has some ideas for a well design solution ?
Define model listener ( dataPopulated(Event e))
Make your view implement model listener and register it with the Model.
Define a Model class that can contain the objects that you want to populate in the view
When Model.setInput(Object input) is invoked fire dataPopulated() event on all registered model listeners.
Above steps works properly when you have view activated. You need to consider cases like when if view is deactivated or not visible ( make sure you refresh view is visible else you will have unnecessary overhead of refreshing view though it is notvisible)
Try adding a selection listener in the view and register this selection in the dialog.
In the listener action, add the code to show the selected object.

What triggers the pyqt dragLeaveEvent

When I'm dragging an item from a tablewidget, what triggers the the drag events, is it the QTableWidget, or the QTableWidgetItem? Or, something all together different? I need to alter my mimeData when it gets selected and is being dragged to a list.
Ok, I figured out my problem:
It's the QTableWidget that triggers the event. The problem I was having was that I set setDragEnabled(True) after I was trying to use my overridden event function.

Updating a view from a command handler

I have a file dialogue opening from the menu where a user can select a file. The FileDialog is called from the menu command's handler class in execute().
Based on the file the user selected, I would like to update a view, for which (I believe) I'd need the same Composite element that's passed to the view in createPartControl().
Is it possible to get access to it from the command handler, or would it be better to trigger the view updating via something like ISourceProviderListener or PropertyChangeListener?
Thank you.
Yes, it's possible:
IViewPart part = HandlerUtil.getActiveWorkbenchWindow(executionEvent).getActivePage()
.findView(viewId);
It would be better to first update the data that your view is displaying (the model in MVC) and the change in data should trigger view refresh. It's hard to say which listener is better without knowing all the details.