|
Re: FocusListener and mouse [message #461301 is a reply to message #461295] |
Tue, 20 September 2005 14:18 |
Eclipse User |
|
|
|
Originally posted by: ddana78ar.yahoo.com.ar
the tab key, works with the traverseListener.
For your problem with the mouse, I think that you can set:
e.doIt = false;
if you want to stop the event after you have highlighted the text, or into the mouseUp event catching.
|
|
|
|
Re: FocusListener and mouse [message #461306 is a reply to message #461302] |
Tue, 20 September 2005 15:19 |
Eclipse User |
|
|
|
Originally posted by: ddana78ar.yahoo.com.ar
> regarding TraversalListener (i still have problems
> with the term
> Traversal): is that listener responsible for creating
> a chain like "if the
> user presses TAB go to widget a, next TAB got tow
> widget b, next TAB
> widget c" and so on?
yes, its by default. But if you want to cange that order, you have to create a collection with the widgets and "force" the next.
|
|
|
|
Re: FocusListener and mouse [message #461310 is a reply to message #461308] |
Tue, 20 September 2005 16:47 |
Eclipse User |
|
|
|
Originally posted by: ddana78ar.yahoo.com.ar
------=_Part_51_21678526.1127235016134
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
look at this.
regards
------=_Part_51_21678526.1127235016134
Content-Type: application/octet-stream; name=TraverseTestingDefault.java
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=TraverseTestingDefault.java
/*
* Created on 20-sep-2005
* by DDana
*/
package testing;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class TraverseTestingDefault {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FormLayout());
Text t1 = new Text(shell,SWT.BORDER);
t1.setText("t1");
Text t2 = new Text(shell,SWT.BORDER);
t2.setText("t2");
Text t3 = new Text(shell,SWT.BORDER);
t3.setText("t3");
Text t4 = new Text(shell,SWT.BORDER);
t4.setText("t4");
FormData data = new FormData();
data.width = 50;
data.top = new FormAttachment(0,0);
data.left = new FormAttachment(0,0);
t1.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(0,0);
data.left = new FormAttachment(t1,0);
t2.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(t1,0);
data.left = new FormAttachment(0,0);
t3.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(t1,0);
data.left = new FormAttachment(t3,0);
t4.setLayoutData(data);
FocusListener focusListener = new FocusListener() {
public void focusLost(FocusEvent e) {
}
public void focusGained(FocusEvent e) {
String text = ((Text)e.widget).getText();
((Text)e.widget).setSelection(0,text.length());
}
};
t1.addFocusListener(focusListener);
t2.addFocusListener(focusListener);
t3.addFocusListener(focusListener);
t4.addFocusListener(focusListener);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}
------=_Part_51_21678526.1127235016134
Content-Type: application/octet-stream; name=TraverseTestingForce.java
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=TraverseTestingForce.java
/*
* Created on 20-sep-2005
* by DDana
*/
package testing;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class TraverseTestingForce {
private static Text t1,t2,t3,t4;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FormLayout());
shell.setLocation(200,200);
t1 = new Text(shell,SWT.BORDER);
t1.setText("t1");
t2 = new Text(shell,SWT.BORDER);
t2.setText("t2");
t3 = new Text(shell,SWT.BORDER);
t3.setText("t3");
t4 = new Text(shell,SWT.BORDER);
t4.setText("t4");
FormData data = new FormData();
data.width = 50;
data.top = new FormAttachment(0,0);
data.left = new FormAttachment(0,0);
t1.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(0,0);
data.left = new FormAttachment(t1,0);
t2.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(t1,0);
data.left = new FormAttachment(0,0);
t3.setLayoutData(data);
data = new FormData();
data.width = 50;
data.top = new FormAttachment(t1,0);
data.left = new FormAttachment(t3,0);
t4.setLayoutData(data);
TraverseListener traverseListener = new TraverseListener() {
public void keyTraversed(TraverseEvent e) {
nextWidget(e);
}
};
t1.addTraverseListener(traverseListener);
t2.addTraverseListener(traverseListener);
t3.addTraverseListener(traverseListener);
t4.addTraverseListener(traverseListener);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
protected static void nextWidget(TraverseEvent e) {
if (((Text)e.widget) == t2){
t4.setFocus();
t4.setSelection(0,t4.getText().length());
e.doit = false;
}
}
}
------=_Part_51_21678526.1127235016134--
|
|
|
Powered by
FUDForum. Page generated in 0.07324 seconds