[brailleblaster] Re: The VerifyKeyListener

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Sat, 11 Jun 2011 23:13:03 +0100

I had slightly different cases for when no key press may cause a change, but you have the idea.


My thought on what should say when a change occurs, if using the model, view, controller pattern, the StyledText is only the view, surely what you should be listening to for change events would be your document model. What precisely is the document model in BrailleBlaster I do not know, but I suppose a XML DOM could be seen as one. However a XML DOM object I don't think offers the events to inform of a change to the document model, so may be we need to create something custom which might use the services of a DOM. In fact using MVC and observer would make this really easy, as the views would anyway be listening for events of changes to the underlying model and so the "change monitor" would simply just add itself to the listeners for the events relating to change (just like another view).

Michael Whapples
On 06/11/11 22:57, John J. Boyer wrote:
Actually, I've been wondering about this also. A document can be changed
by replacing some text with some other, or by deleting text. The Modify
and ExtendedModify listeners seem to detect this, but the documentation
doesn't say wht the difference between them is. Conceivably text chold
be changed by mouse action alone. Moreover, we aren't really concerned
with text. We will be hasndling graphics. So we need to know when a
graphic has changed. This might be by mouse action alone, for example,
dragging or resizing it.

John

On Sat, Jun 11, 2011 at 10:33:14PM +0100, Michael Whapples wrote:
Hello,
May be I have lost where we are going here, but a question which may
need to be asked is, what determines if the "document" has changed? Is
it as simple as only key presses in the styled text controls may change
the document? Is there any other way the document may be modified? Can
the view provide sufficient information of whether the document has
changed? Just because a document looks the same, does that mean the
actual document itself is the same?

Michael Whapples
On 06/11/11 16:51, Susan Jolly wrote:
The StyledText widget has a lot of OS-dependent default key bindings
which you can discover either from its getKeyBinding() method or by
looking at the source code.  You can overwrite the defaults and/or set
additional bindings with the widget's setKeyBinding() method. You can
listen directly for SWT.Key_Down events rather than
usingVerifyKeyListener. . Here is a bit of code from the TextEditor
example.

styledText.addListener(SWT.KeyDown, new Listener() {
  public void handleEvent(Event event) {
   handleKeyDown(event);
  }

Then in your handleKeyDown() method you can use event.keyCode to
determine which key was pressed.

Susan



Other related posts: