Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 111013 Details for
Bug 245315
[SWT] Combo texts cannot be made read-only to users and writable by code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Test class
ComboTest.java (text/plain), 2.29 KB, created by
Nobody - feel free to take it
on 2008-08-26 18:30:53 EDT
(
hide
)
Description:
Test class
Filename:
MIME Type:
Creator:
Nobody - feel free to take it
Created:
2008-08-26 18:30:53 EDT
Size:
2.29 KB
patch
obsolete
>import org.eclipse.swt.SWT; >import org.eclipse.swt.events.ModifyEvent; >import org.eclipse.swt.events.ModifyListener; >import org.eclipse.swt.events.SelectionAdapter; >import org.eclipse.swt.events.SelectionEvent; >import org.eclipse.swt.events.VerifyEvent; >import org.eclipse.swt.events.VerifyListener; >import org.eclipse.swt.widgets.Combo; >import org.eclipse.swt.widgets.Display; >import org.eclipse.swt.widgets.Event; >import org.eclipse.swt.widgets.Shell; > >public class ComboTest >{ > private static boolean allow; > > public static void main(String[] args) > { > final Display display = new Display(); > final Shell shell = new Shell(display); > > final Combo combo = new Combo(shell, SWT.DROP_DOWN); > combo.setBounds(10, 10, 100, 20); > combo.setItems(new String[] {"unu", "doi", "trei", "patru", "cinci"}); > > combo.addModifyListener(new ModifyListener() > { > public void modifyText(ModifyEvent e) > { > System.out.println("modify -> $" + combo.getText() + '$' + combo.getSelectionIndex()); > } > }); > > combo.addSelectionListener(new SelectionAdapter() > { > public void widgetSelected(SelectionEvent e) > { > System.out.println("select -> $" + combo.getText() + '$' + combo.getSelectionIndex()); > > Event verifyEvent = new Event(); > verifyEvent.display = display; > verifyEvent.doit = true; > verifyEvent.start = 0; > verifyEvent.end = combo.getText().length(); > verifyEvent.widget = combo; > verifyEvent.time = (int) System.currentTimeMillis(); > verifyEvent.text = combo.getItem(combo.getSelectionIndex()); > > allow = true; > combo.notifyListeners(SWT.Verify, verifyEvent); > combo.notifyListeners(SWT.Modify, verifyEvent); >// combo.select(combo.getSelectionIndex()); >// combo.setText(combo.getItem(combo.getSelectionIndex())); > allow = false; > } > }); > > combo.addVerifyListener(new VerifyListener() > { > private long lastTime; > > public void verifyText(VerifyEvent e) > { > System.out.print("verify -> $" + combo.getText() + '$' + combo.getSelectionIndex() + "\t\t\t"); > System.out.println("from " + e.start +" to " + e.end + " &" + e.text +"&"); > > if (allow) > return; > e.doit = false; > } > }); > > shell.pack(); > shell.open(); > while (! shell.isDisposed()) > { > if (! display.readAndDispatch()) > display.sleep(); > } > display.dispose(); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 245315
: 111013