Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » disable cut/copy/paste on StyledText
disable cut/copy/paste on StyledText [message #331744] Fri, 19 September 2008 09:58 Go to next message
Sheela is currently offline SheelaFriend
Messages: 52
Registered: July 2009
Member
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Sheela is currently offline SheelaFriend
Messages: 52
Registered: July 2009
Member
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
Re: disable cut/copy/paste on StyledText [message #331780 is a reply to message #331744] Mon, 22 September 2008 13:30 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Sheela wrote:
> 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.

In an eclipse editor? Are you supplying a handler to the
org.eclipse.ui.edit.cut command or a global action handler to
ActionFactory.CUT.getId()?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm


Previous Topic:[De]serialization of objects in plugin
Next Topic:How to handle multiple instances of views and handlers
Goto Forum:
  


Current Time: Thu Dec 26 21:17:15 GMT 2024

Powered by FUDForum. Page generated in 0.03004 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top