Lost focus and misshandling of input slot edits [FIXED]

(Read-only) To re-open a bug, start a new thread in the Bugs forum.

Moderator: MSandro

Locked
bromagosa
Posts: 33
Joined: Sep 15th, '15, 07:11

Lost focus and misshandling of input slot edits [FIXED]

Post by bromagosa » Oct 29th, '15, 11:37

I've apparently managed to fix this issue.

What was happening is, for instance, if you modified an input slot and immediately clicked on Go, instead of first clicking somewhere else to get the caret out of the input slot, the modification wouldn't take effect and, although the input slot would show the new value, its actual contents would be the old ones. What I've done is telling the caret to notify the input slot that its text has changed:

Code: Select all

method textinput Caret evt keyboard {
  char = (at evt 'text')
  if ('numerical' == (editRule target)) {
    if (not (or (isDigit char) ('.' == char) ('-' == char))) { return }
  }
  insertRight this char

  parent = (parentHandler (morph target))
  if (isClass parent 'InputSlot') {
    textChanged parent
  }
}
This almost works, but still if you click on Go before getting the caret out of the slot, the caret stays there and you end up with multiple carets, and only one of them is actually working:

Image

So, to handle that, when instantiating a new Caret I'm destroying all the other carets:

Code: Select all

method initialize Caret aText initialSlot {
  for c (allInstances 'Caret') {
    if (c != this) { destroy c }
  } 
  morph = (newMorph this)
  setFPS morph 2
  if (notNil aText) {
    edit this aText initialSlot
	showKeyboard true
  }
}
This does work, but I'm not sure it complies with GP's code style. I'm just beginning to get a hang of the language...

I hope it's useful!

JohnM
Posts: 379
Joined: Sep 11th, '15, 14:42

Re: Lost focus and misshandling of input slot edits (fixed)

Post by JohnM » Oct 29th, '15, 13:00

Thanks for the fix! Jens has also fixed this bug, although I'm not sure if his fix is in v042. In any case, one of your fixes will make it into the next version.

Locked