[Cuis-dev] Integer/Date/Tiem Input Dialog to pick up a file

Gerald Klix cuis.01 at klix.ch
Fri Jul 14 10:06:51 PDT 2023


On 7/14/23 5:52 PM, Hilaire Fernandes wrote:
> Le 14/07/2023 à 11:53, Gerald Klix a écrit :
>> I presume any one who does serious application programming with Cuis
>> will run into that problem, me included.
>
> That's right.
>
>
>>
>> (I have to confess, that I solved the input problem for times and 
>> dates -- I hope you remeber, that we talked about that one --
>> for Haver, without consulting the community)
>
> Yes, I remember. Did you write dedicated widgets for that? Screenshot?
Currently it looks like this (pretty boring):


There is no text cursor, you just can type numbers,
use the up down arrows or the mouse wheel
to increment or decrement the numbers,
either by one or 10 (6 for hours part of a time input morph)
together with the shift key. The del key zeros the input field,
backspace deletes the last digit. Code probably tells more
than English prose:

keyStroke: aKeyboardEvent
     "Handle a keystroke event."

     | uppercaseCharacter |
     self focusKeyboardFor: aKeyboardEvent :: ifTrue: [ ^ self ].
     "D: Transcript newLine;  show: 'kS: '; show: aKeyboardEvent 
keyCharacter."
     (uppercaseCharacter := aKeyboardEvent keyCharacter asUppercase) 
digitValue
         between: 0 and: self base - 1 ::
             ifTrue: [ self contents: (contents         copyWith: 
uppercaseCharacter) ]
             ifFalse: [
                 aKeyboardEvent keyCharacter caseOf: {
                     [ $- ] -> [ self integer: self integer negated ].
                     [ $+ ] -> [ self integer: self integer abs ] }
                 otherwise:  [ | hand |
                     aKeyboardEvent isDelete ifTrue: [
                         ^ self integer: self initialValue ].
                     aKeyboardEvent isBackspace and: [ contents size > 1 
] :: ifTrue: [
                         ^ self contents: (contents copyFrom: 1 to: 
contents size - 1) ].
                     aKeyboardEvent isArrowUp ifTrue: [
                         ^ self increment: aKeyboardEvent shiftPressed ].
                     aKeyboardEvent isArrowDown ifTrue: [
                         ^ self decrement: aKeyboardEvent shiftPressed ].
                     hand := aKeyboardEvent hand.
                     aKeyboardEvent isArrowLeft ifTrue: [
                         ^ hand keyboardFocusPreviousWithinWindow ].
                     aKeyboardEvent isArrowRight ifTrue: [
                         ^ hand keyboardFocusNextWithinWindow ].
                     aKeyboardEvent isTab ifTrue: [
                         ^ aKeyboardEvent shiftPressed
                             ifTrue: [ hand 
keyboardFocusPreviousWithinWindow ]
                             ifFalse: [ hand 
keyboardFocusNextWithinWindow ] ].
                     self flash ] ]
Alas this (probably) depends on Haver's changed keyboard focus handling.

The class is a subclass of label morph:
LabelMorph subclass: #SimpleIntegerInputMorph
     instanceVariableNames: 'numberOfDigits bigDelta littleDelta blinkOn 
base checkBlock valueBlock'
     classVariableNames: ''
     poolDictionaries: ''
     category: 'ValueEditors-SimpleMorphs'
     inModule: #ValueEditors

The remaining stuff uses this SimpleIntegerInputMorph class to build
an integer input morph with a model, which is then combined
to create a time and a date input morph classes, which in turn are combined
to create a date and time input morphs.
All of this uses subclasses of Haver's AbstractSystemMorph and
AbstractSystemMorphModel classes.


>
>>
>> What do you have in mind? Something like the attached screen shot?
>
> Indeed
>
>
>>
>> BTW: Are there any primitives (in the VM) that answer
>> the user's home directory, the available drives and other
>> filesystem related information? 
>
> For the home directory, I did not find it, I passed the info from the 
> bash start script
One could use the OSProcess-package, with its dependencies, to
to retrieve environment variables like HOME.
>
> Hilaire
>


HTH,

Gerald
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230714/cae477a6/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fojmlhfomnlpmjfd.jpeg
Type: image/jpeg
Size: 3047 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230714/cae477a6/attachment.jpeg>


More information about the Cuis-dev mailing list