disable cut/copy/paste on StyledText [message #331744] |
Fri, 19 September 2008 09:58  |
Eclipse User |
|
|
|
Hi,
I have created a header partition in my editor and made it uneditable by
implementing verifyText() method of VerifyListener which is a listener on
the StyledText.
It is working perfectly (and does not allow any keyboard modifications to
the header) except that I am still able to cut a part of the header or
paste some text in the header.
How do I disable the cut/copy/paste actions in the partition ?
Thanks in Advance
Regards,
Sheela
|
|
|
Re: disable cut/copy/paste on StyledText [message #331758 is a reply to message #331744] |
Fri, 19 September 2008 19:20   |
Eclipse User |
|
|
|
Hi Sheela,
In the snippet below cut and paste are successfully vetoed. Copy still
happens, but this should not be a big problem since it does not modify the
StyledText's content. Does the snippet below work similarly for you? And
if so, can you change it in a way that makes it show your problem?
public static void main (String [] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
shell.setLayout(new FillLayout());
StyledText text = new StyledText(shell, SWT.NONE);
text.setText("hihihihi");
text.addListener(SWT.Verify, new Listener() {
public void handleEvent(Event event) {
event.doit = false;
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
Grant
"Sheela " <sheela_kalyanpur@infosys.com> wrote in message
news:159b1ad8786d86425886e25b641abffc$1@www.eclipse.org...
> Hi,
>
> I have created a header partition in my editor and made it uneditable by
> implementing verifyText() method of VerifyListener which is a listener on
> the StyledText.
> It is working perfectly (and does not allow any keyboard modifications to
> the header) except that I am still able to cut a part of the header or
> paste some text in the header.
>
> How do I disable the cut/copy/paste actions in the partition ?
>
> Thanks in Advance
>
> Regards,
> Sheela
>
|
|
|
Re: disable cut/copy/paste on StyledText [message #331775 is a reply to message #331758] |
Mon, 22 September 2008 05:27   |
Eclipse User |
|
|
|
Hi Grant,
Thanks for responding to my post.
I hv provided my code snippet below (which is a implemented in my
ScriptEditor class)
public void createPartControl(Composite parent) {
super.createPartControl(parent);
// get the sourceviewer of the current document
ISourceViewer viewer = getScriptSourceViewer();
// get the styled text on which the listener will be added
final StyledText styledText= viewer.getTextWidget();
// add verify listener on the styled text
styledText.addVerifyListener(new VerifyListener() {
public void verifyText(VerifyEvent e) {
e.doit = false;
}
});
}
I tried your suggestion , but doesn't seem to work for me.
When i tried to debug, in the event of a cut/paste the call never comes to
verifyText(). Even though your code works perfectly standalone, when i
tried it in my code, and debugged, the call never comes to handleEvent()
when i try to cut/paste. I would be very thankful for your inputs.
Thanks in Advance
Regards,
Sheela
|
|
|
|
Powered by
FUDForum. Page generated in 0.04690 seconds