[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.swt] Re: How to make Canvas selectable?
|
Hi,
thank you for very nice explanation.
BR,
Jan
"Carolyn MacLeod" <Carolyn_MacLeod@xxxxxxxxxx> pí¹e v diskusním pøíspìvku
news:fr6lhr$dso$1@xxxxxxxxxxxxxxxxxxxx
> In your mouse listener, you can call notifyListeners (SWT.Selection, new
> Event()) to send the selection event to anyone who has added it to your
> "button".
> You will also want to:
> - add a key listener and if the event character is a space ' ' then call
> notifyListeners
> - add a traverse listener and if the event detail is SWT.TRAVERSE_TAB_NEXT
> or _PREVIOUS, set the event doit to true
> - you may also want to handle TRAVERSE_RETURN if you want your "button" to
> process carriage returns (i.e. if it can be the "default button" in a
> dialog, for example)
> - you may also want to handle TRAVERSE_MNEMONIC if you want your "button"
> to handle mnemonic key selection (Alt+character)
> - add a paint listener to do the drawing using the GC contained in the
> paint event. One (good) way to show that your "button" has focus is to use
> event.gc.drawFocus() on the client area of the canvas (only if the canvas
> isFocusControl() ), after you have drawn the rest of your button. This
> draws the platform's focus indicator (i.e. dotted rectangle).
> - add a focus listener and redraw() the canvas when focus is gained or
> lost
>
> Hope this helps,
> Carolyn
>
> "Robert B" <oh1226@xxxxxxxxxxx> wrote in message
> news:fr5g3r$qcd$1@xxxxxxxxxxxxxxxxxxxx
>>
>> "Jan" <ahanys@xxxxxxxxx> wrote in message
>> news:fr59kc$c4a$1@xxxxxxxxxxxxxxxxxxxx
>>> Hello,
>>>
>>> I have a question how to extend a Canvas so it can be selected like a
>>> Button?
>>
>> Just add a mouse listener and process when mouseClicked()
>> or mouseReleased().
>>
>> You can draw whatever shape you want in the canvas,
>> an attractive person!
>>
>> R.
>>
>
>