Control of Text Fields.

Richmond richmondmathewson at gmail.com
Sat Nov 6 15:04:46 EDT 2021


My competing version is now "up":

https://forums.livecode.com/viewtopic.php?f=7&t=36444&p=210241#p210241

Richmond.

On 5.11.21 23:08, Alex Tweedly via use-livecode wrote:
>
> On 05/11/2021 20:18, Roger Guay via use-livecode wrote:
>> Alex, I did not see that and it is not in my mailbox. Would you 
>> please send it again?
>>
>> Thanks,
>> Roger
>
> Here it is again, below.
>
> Or download the sample stack at 
> https://tweedly.org/downloads/calcbuttons.livecode
>
>  - not as pretty as Richmond's, doesn't even have all the digits ...)
>
> Previously I said:
>
> Here's an expanded snippet. The input is in a field called "fInput", 
> the buttons are all in a group, and handled by the group script (saves 
> having many tiny almost identical scripts).
>
> The script  uses the name of the target - but since I would never, 
> ever have a control named as a number, the digit buttons use their 
> label instead.
>
> If the user cannot select a chunk of text then some of this could be 
> shortened.
>
>
>> on mouseup
>>    if the target = me then
>>       -- click in the background in the group
>>       exit mouseup
>>    end if
>>    local tChunk
>>    focus on fld "fInput"
>>    put the selectedchunk into tChunk
>>    if the label of the target is a number then
>>       put the label of the target into the selectedchunk
>>       exit mouseUp
>>    end if
>>    local tFirst, tLast
>>    put word 2 of tChunk into tFirst
>>    put word 4 of tChunk into tLast
>>    switch the short name of the target
>>       case "go left"
>>          select before char (min(tFirst, tLast)) of fld "fInput"
>>          break
>>       case  "go right"
>>          select after char (max(tFirst, tLast)) of fld "fInput"
>>          break
>>       case "Del"
>>          -- remove the selection, or the char *after* the ibeam
>>          if tFirst <= tLast then
>>             put empty into char tFirst to tLast of fld "fInput"
>>          else
>>             put empty into char (tFirst) of fld "fInput"
>>          end if
>>          break
>>       case "BS"
>>          -- remove the selection, or the char *before* the ibeam
>>          if tFirst <= tLast then
>>             put empty into char tFirst to tLast of fld "fInput"
>>          else
>>             put empty into char (tFirst-1) of fld "fInput"
>>          end if
>>          break
>>          -- all the other keys !!
>>       default
>>    end switch
>> end mouseup
>
> Alex.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list