Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1514.mcz ==================== Summary ==================== Name: Morphic-mt.1514 Author: mt Time: 5 September 2019, 2:36:47.777837 pm UUID: 49f63b40-72ce-c447-9fb0-9400ea43fab2 Ancestors: Morphic-mt.1513, Morphic-ct.1501 Merges Morphic-ct.1500. and 1501. Can't we just filter for #isAlphaNumeric? Do we need parentheses etc.? Would be more readable than ">= 32". I also do not think that #caseOf: helps much in terms of readability. ;-) =============== Diff against Morphic-mt.1513 =============== Item was changed: ----- Method: MenuMorph>>handleFiltering: (in category 'keystroke helpers') ----- handleFiltering: evt | matchString | matchString := self valueOfProperty: #matchString ifAbsentPut: [ String new ]. + matchString := true + caseOf: { + [ evt keyCharacter = Character backspace ] -> + [ matchString isEmpty + ifTrue: [ matchString ] + ifFalse: [ matchString allButLast ] ]. + [ evt keyValue >= 32 ] -> + [ matchString , evt keyCharacter ] } + otherwise: [ matchString ]. - matchString := evt keyValue = 8 " Character backspace asciiValue " - ifTrue: [ - matchString isEmpty - ifTrue: [ matchString ] - ifFalse: [ matchString allButLast ] ] - ifFalse: [ - matchString copyWith: evt keyCharacter ]. self setProperty: #matchString toValue: matchString. self displayFiltered: evt! |
Personally, I sometimes type-to-filter a menu for things like '...' or ' ' (space). Am I the only one who does this? :)
I still would consider something like Character>>#isControlCharacter useful. How about this?
Unicode class>>isControlCode: charCode
^ (self generalCategoryOf: charCode) <= Cs
Character>>isControlCharacter
^ self encodedCharSet isControlCode: self charCode
Versions for other char sets would have to be added.
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Donnerstag, 5. September 2019 14:36:59 An: [hidden email]; [hidden email] Betreff: [squeak-dev] The Trunk: Morphic-mt.1514.mcz Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1514.mcz ==================== Summary ==================== Name: Morphic-mt.1514 Author: mt Time: 5 September 2019, 2:36:47.777837 pm UUID: 49f63b40-72ce-c447-9fb0-9400ea43fab2 Ancestors: Morphic-mt.1513, Morphic-ct.1501 Merges Morphic-ct.1500. and 1501. Can't we just filter for #isAlphaNumeric? Do we need parentheses etc.? Would be more readable than ">= 32". I also do not think that #caseOf: helps much in terms of readability. ;-) =============== Diff against Morphic-mt.1513 =============== Item was changed: ----- Method: MenuMorph>>handleFiltering: (in category 'keystroke helpers') ----- handleFiltering: evt | matchString | matchString := self valueOfProperty: #matchString ifAbsentPut: [ String new ]. + matchString := true + caseOf: { + [ evt keyCharacter = Character backspace ] -> + [ matchString isEmpty + ifTrue: [ matchString ] + ifFalse: [ matchString allButLast ] ]. + [ evt keyValue >= 32 ] -> + [ matchString , evt keyCharacter ] } + otherwise: [ matchString ]. - matchString := evt keyValue = 8 " Character backspace asciiValue " - ifTrue: [ - matchString isEmpty - ifTrue: [ matchString ] - ifFalse: [ matchString allButLast ] ] - ifFalse: [ - matchString copyWith: evt keyCharacter ]. self setProperty: #matchString toValue: matchString. self displayFiltered: evt!
Carpe Squeak!
|
Hi,
any opinions about this proposal? :-)
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Thiede, Christoph
Gesendet: Donnerstag, 5. September 2019 15:06 Uhr An: [hidden email]; [hidden email] Betreff: Re: [squeak-dev] The Trunk: Morphic-mt.1514.mcz Personally, I sometimes type-to-filter a menu for things like '...' or ' ' (space). Am I the only one who does this? :)
I still would consider something like Character>>#isControlCharacter useful. How about this?
Unicode class>>isControlCode: charCode
^ (self generalCategoryOf: charCode) <= Cs
Character>>isControlCharacter
^ self encodedCharSet isControlCode: self charCode
Versions for other char sets would have to be added.
Best,
Christoph
Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Donnerstag, 5. September 2019 14:36:59 An: [hidden email]; [hidden email] Betreff: [squeak-dev] The Trunk: Morphic-mt.1514.mcz Marcel Taeumel uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-mt.1514.mcz ==================== Summary ==================== Name: Morphic-mt.1514 Author: mt Time: 5 September 2019, 2:36:47.777837 pm UUID: 49f63b40-72ce-c447-9fb0-9400ea43fab2 Ancestors: Morphic-mt.1513, Morphic-ct.1501 Merges Morphic-ct.1500. and 1501. Can't we just filter for #isAlphaNumeric? Do we need parentheses etc.? Would be more readable than ">= 32". I also do not think that #caseOf: helps much in terms of readability. ;-) =============== Diff against Morphic-mt.1513 =============== Item was changed: ----- Method: MenuMorph>>handleFiltering: (in category 'keystroke helpers') ----- handleFiltering: evt | matchString | matchString := self valueOfProperty: #matchString ifAbsentPut: [ String new ]. + matchString := true + caseOf: { + [ evt keyCharacter = Character backspace ] -> + [ matchString isEmpty + ifTrue: [ matchString ] + ifFalse: [ matchString allButLast ] ]. + [ evt keyValue >= 32 ] -> + [ matchString , evt keyCharacter ] } + otherwise: [ matchString ]. - matchString := evt keyValue = 8 " Character backspace asciiValue " - ifTrue: [ - matchString isEmpty - ifTrue: [ matchString ] - ifFalse: [ matchString allButLast ] ] - ifFalse: [ - matchString copyWith: evt keyCharacter ]. self setProperty: #matchString toValue: matchString. self displayFiltered: evt!
Carpe Squeak!
|
|
Menu filtering is so cool! :-) And convenient. This proposal about #isControlCharacter aims at preventing malformed user input. For example, the user might wonder if a filter does strange things only because the system cannot render certain (wrongly) typed characters. An easier solution would be to render "?" or something similar for such characters. Then, the user can recognize the bad input and hit the [backspace] key. This way, we do not constrain ourselves to a specific range of menu labels at all. :-) Best, Marcel
|
On Mon, Oct 7, 2019 at 1:29 AM Marcel Taeumel <[hidden email]> wrote:
-1. We should let the machine do the recognition and backspacing -- e.g., any character which causes all selections of a menu to be grayed out should cause that character to be rejected. Perhaps with a beep or flash of the menu. Note this would provide a more consistent UI with the list-filtering, which behaves that way. Menus should be constrained English, with use of #translated for other languages with special characters. Best, Chris
|
Chris,
I did not forget this thread :)
My personal opinion is that the menu-filtering is actually more convenient (at least to me). If you type a non-matching filter term into a list morph (for example, "hello world" into the System Browser's class list), the filtering "breaks" half the way and a partial match is selected. If you are doing the same in a menu morph, however, each character is recorded so you can correct typing errors, and you do not need to check your results before pressing Enter. It happens so often that I type something wrong and get irritated as the whole list "stops working", not accepting any further character. I think menus are just convenient as they are, rather I would change the list implementation to show nothing (but maybe a "no-hit message"?) if nothing matches your filter term.
However, we were talking about refactoring. Do you actually think that "keyValue >= 32" in a morph class should be preferred to a string utility that gives the thing we want to do a clear name?
Best, Christoph Von: Squeak-dev <[hidden email]> im Auftrag von Chris Muller <[hidden email]>
Gesendet: Montag, 7. Oktober 2019 20:30:42 An: The general-purpose Squeak developers list Betreff: Re: [squeak-dev] #isControlCharacter (was: The Trunk: Morphic-mt.1514.mcz) On Mon, Oct 7, 2019 at 1:29 AM Marcel Taeumel <[hidden email]> wrote:
-1. We should let the machine do the recognition and backspacing -- e.g., any character which causes all selections of a menu to be grayed out should cause that character to be rejected. Perhaps with a beep or flash of the menu. Note this would provide
a more consistent UI with the list-filtering, which behaves that way.
Menus should be constrained English, with use of #translated for other languages with special characters.
Best,
Chris
Carpe Squeak!
|
Hi Christoph,
You're right. And, you've even reminded me of one of my own UI principles that, in general, a unidirectional interaction -- where the user can direct the software without needing visual feedback -- is better wherever possible. In this case, you can input via keyboard without having to read the screen, and even if you make a typing mistake, you can still direct it to your selection unidirectionally. [End] key probably not hit while filtering, but when [Backspace]ing, so I think your tweak is fine. :) Lists aren't as predictable as menus, so two-way interaction is probably unavoidable, and if we displayed an empty list there'd be no place to display the current filter string..
No, I think clarity is better. But not a new extension method. More like how you improved the line higher up in the method from evt keyValue = 8 " Character backspace asciiValue " to evt keyCharacter = Character backspace I think you should've stuck with your improved pattern for the >=32 check, e.g., evt keyCharacter >= Character space and maybe a terse comment for why. I certainly wouldn't make a whole new version of Morphic only for that, though. Best, Chris
|
Free forum by Nabble | Edit this page |