SWT Popup-Menu Problem (Position)

Status
Nicht offen für weitere Antworten.

ich_wills_wissen

Bekanntes Mitglied
Hallo zusammen,

ich tüftel nun schon seit Stunden hier rum und komme nicht weiter.
Es geht um folgendes:
Ich schreibe derzeit ein Eclipse Plugin. Innerhalb des Plugins gibt es eine Klasse "TopicView" die von ViewPart erbt ("TopicView extends ViewPart").
Innerhalb von Viewpart habe ich ein Composite, welches wiederum ein Label enthält. Ich möchte nun Folgendes:
Wenn ich mit der rechten Maustaste auf das Label klicke soll ein Popup-menu erscheinen (und zwar dort wo der Mauszeiger ist).
Das Problem: Das Popupmenu erscheint, allerdings nicht da wo der Mauszeiger ist!

Mein Code:
Code:
public void mouseDown(MouseEvent e)
         {
            
            if(e.button == 3)
            {
               Menu menu = new Menu(label);
               menu.setLocation(e.x,e.y);
               MenuItem item = new MenuItem(menu, SWT.PUSH);
                 item.setText("Menu Item");
                 item.addListener(SWT.Selection, new Listener() {
                    public void handleEvent(Event e)    
                    {
                       System.out.println("Item Selected");
                    }});
                
                 menu.setVisible(true);
                 while (!menu.isDisposed() && menu.isVisible()) {
                   if (!Display.getCurrent().readAndDispatch())
                     Display.getCurrent().sleep();
                 }
                 menu.dispose();
            }
            
            
         }
      });
Wenn ich nur e.x und e.y ausgeben lasse zeigt er die Koordinaten innerhalb des labels an, also z.B. 4 (x) und 17(y). Das Popupmenu zeichnet sich auch an diesen Koordinaten, allerdings nicht relativ zum Label sondern zum Bildschirm, d.h. Das Popupmenu erscheint ganz links oben auf dem Bildschirm!
Ich weiß so langsam echt nichtmehr weiter.. hat jemand zufällig eine Idee wie ich das lösen kann ? Wäre echt toll..

Verzweifelt-entnervte Grüße,

ich_wills_wissen
 

ich_wills_wissen

Bekanntes Mitglied
merlin2 hat gesagt.:
Vielleicht mit
e.x+label.x, e.y+label.y
oder label.getLocationOnScreen() ?

Also die Methode label.getLocationOnScreen existiert irgendwie nicht.. sicher das wir beide gerade über das Gleiche reden? ;-)
Das Label ist ein org.eclipse.swt.widgets.Label...
Auch das CLabel kennt diese Methode nicht.

e.x+label.x, e.y+label.y bringt leider nicht das gewünschte Ergebnis, weil label.x und label.y die Koordinaten relativ zum Parent liefern und nicht zum Display..
 
Status
Nicht offen für weitere Antworten.
Ähnliche Java Themen
  Titel Forum Antworten Datum
M Erweitern Popup - Menüs für Eclipse Outline Plattformprogrammierung 2
S RCP Menu Contribution - Menü Button wird als inaktiv angezeigt Plattformprogrammierung 11
K Menu im MultiPageEditor Plattformprogrammierung 3
G Command und Context Menu Plattformprogrammierung 2
M Eclipse RCP: Context Menu für MultiPageEditor erzeugen... Plattformprogrammierung 6
C RCP - dynamische actions in menu extention programmieren Plattformprogrammierung 4
K Problem bei Einbinden einer DLL in Java-Projekt Plattformprogrammierung 4
Wurstsemmel RCP SWT-Problem: Programm sucht Cocoa-Bibliothek unter Windows Plattformprogrammierung 6
Shams Antbuild - Problem bei OSGi Anfängertutorial Plattformprogrammierung 0
D Problem mit eclipse Plattformprogrammierung 2
J JNA Implimentierungs Problem Plattformprogrammierung 0
Shams Problem bei der Knopflerfischinstallation Plattformprogrammierung 2
J Charset-Problem nach Plugin-Export Plattformprogrammierung 1
TheWhiteShadow RCP Problem mit Plugin Interaktion Plattformprogrammierung 6
D Eclipse_Visual Editor Problem Plattformprogrammierung 2
J Eclipse Plug-In für UML-Diagramme Problem Plattformprogrammierung 4
O Eclipse Plugin - Einfachstes Problem, das es gibt. Plattformprogrammierung 2
dzim OSGi Problem beim Verwenden von Declaratice Services Plattformprogrammierung 18
T netbeans problem? Plattformprogrammierung 4
dzim RCP Problem mit MenuManager Plattformprogrammierung 3
H RCP Problem mit Extension Schema Plattformprogrammierung 10
R JFace Databinding Problem Plattformprogrammierung 5
F Ecilpse plugin und MWE Workflow: classpath Problem Plattformprogrammierung 12
W Wahrscheinlich triviales Problem, aber komm nicht weiter Plattformprogrammierung 7
K SelectionListener / SelectionProvider Problem Plattformprogrammierung 2
M Xpand Anfäger Problem Plattformprogrammierung 3
K Eclipse RCP, EMF, Hibernate Problem Plattformprogrammierung 7
dzim RCP Problem mit Umsetzen des Workspace unter Win Plattformprogrammierung 4
B PreferencesService Problem Plattformprogrammierung 2
K EMF/Teneo EMap Problem Plattformprogrammierung 6
K Problem mit EMF/Teneo, GregorianCalendar, Date, Hibernate Timestamp Plattformprogrammierung 6
L RCP TreeViewer Listener Problem Plattformprogrammierung 12
C target platform problem Plattformprogrammierung 2
K NoClassDefFoundError Problem Plattformprogrammierung 24
F Eclipse: Plug-In mit Ecoding Problem Plattformprogrammierung 7
O Problem mit relativen Pfaden in einem RCP-Plugin Plattformprogrammierung 5
dzim Problem beim neuanlegen von Composites Plattformprogrammierung 4
hdi Problem bei Eclipse Plugin Export Plattformprogrammierung 9
K Bild Problem in exportierter RCP Anwendung Plattformprogrammierung 5
M Problem beim Zugriff auf Klasse aus Fragment in einem anderen Plugin Plattformprogrammierung 3
D Problem mit Synth Painter und OSGi (Equinox) Plattformprogrammierung 8
G plugin.xml Problem Plattformprogrammierung 4

Ähnliche Java Themen

Neue Themen


Oben