[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: How to create dynamic context menu which items change related to right-click position?

Thanks, I made it!

"Grant Gayed" <grant_gayed@xxxxxxxxxx> wrote in message 
news:g38eoc$ms4$1@xxxxxxxxxxxxxxxxxxxx
> (disclaimer: TextViewer comes from jface so I don't have much experience
> using it)
>
> I think you can invoke getControl() on it and cast its result to a
> StyledText.  You can then use StyledText.getOffsetAtLocation(Point) to 
> turn
> your mouse click's x,y into a text offset.  There isn't a way to turn this
> offset into a word directly, but you can sniff the characters to the left
> and right of it to determine where the word starts and ends.
>
> Grant
>
>
> "Anakkapan K." <anakkapan_k@xxxxxxxxxxxxxxx> wrote in message
> news:g3786r$6g2$1@xxxxxxxxxxxxxxxxxxxx
>> Thanks for that, but I may be unclearly explained my situation.
>>
>> For now, forget that CompoundContributionItem and use SWT style menu. But
>> the widget that the context menu worked on is a TextViewer. What I want 
>> is
>> get the word at the point I right-clicked on.
>>
>> Any suggestion??
>>
>> "Grant Gayed" <grant_gayed@xxxxxxxxxx> wrote in message
>> news:g35vaa$rc3$1@xxxxxxxxxxxxxxxxxxxx
>> > At the swt level this would be done as demonstrated in:
>> >
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet73.java?view=co
>> >
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet97.java?view=co
>> >
>> > However I don't know how directly this translates to the world of
>> > CompoundContributionItem because this is above the swt level.  If you
>> > don't
>> > get an answer to this here then you should ask on the eclipse.platform
>> > newsgroup.
>> >
>> > Grant
>> >
>> >
>> > "Anakkapan K." <anakkapan_k@xxxxxxxxxxxxxxx> wrote in message
>> > news:g35aej$gn6$1@xxxxxxxxxxxxxxxxxxxx
>> >> I try to create dynamic context menu using CompoundContributionItem,
> but
>> >> I
>> >> want those menu items change related to right-click position. How can 
>> >> I
>> > get
>> >> the mouse position when I'm in CompoundContributionItem or is there
>> >> anyway
>> >> else to archieve my goal?
>> >>
>> >>
>> >
>> >
>>
>>
>
>