Align baselines of 2 fields

Bob Sneidar bobsneidar at iotecdigital.com
Thu Jun 21 13:59:26 EDT 2018


I changed the font of one of the fields to something with a different descent, and it doesn't seem to work. 

Bob S


> On Jun 21, 2018, at 10:28 , Knapp Martin via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> This works for me, assuming you want to leave field 1 where it is and align field 2:
> 
> on alignFieldBaselines pField1, pField2
>  local tDescent1, tDescent2, tBot1, tBot2, tDiff1, tDiff2, tRef
>  local fFormattedBottom1, fFormattedBottom2
> 
>  put item 4 of the formattedRect of line 1 of fld pField1 into fFormattedBottom1
>  put item 4 of the formattedRect of line 1 of fld pField2 into fFormattedBottom2
> 
>  put item 4 of measureText(line 1 of fld pField1, fld pField1 ,"bounds") into tDescent1
>  put item 4 measureText(line 1 of fld pField2, fld pField2 ,"bounds") into tDescent2
> 
>  put the bottom of fld pField1 into tBot1
>  put the bottom of fld pField2 into tBot2
> 
>  put tBot1 - fFormattedBottom1 + tDescent1 into tDiff1
>  put tBot2 - fFormattedBottom2 + tDescent2 into tDiff2
> 
>  put the bottom of fld pField1 -(tDiff1 - tDiff2) into tRef
> 
>  set the bottom of fld pField2 to tRef   
> end alignFieldBaselines
> ---
> Marty
> 
>> On Jun 21, 2018, at 10:24 AM, Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> I modified as follows, but pField2 is one pixel high. Not sure why. 
>> 
>> Bob S
>> 
>> on alignFieldBaselines pField1, pField2
>>  local tDescent1, tDescent2, tBot1, tBot2, tDiff1, tDiff2, tRef
>>  local fFormattedBottom1, fFormattedBottom2
>> 
>>  -- put 120 into tRef
>> 
>>  put item 4 of the formattedRect of line 1 of pField1 into fFormattedBottom1
>>  put item 4 of the formattedRect of line 1 of pField2 into fFormattedBottom2
>> 
>>  put item 4 of measureText(line 1 of pField1, pField1 ,"bounds") into tDescent1
>>  put item 4 measureText(line 1 of pField2, pField2 ,"bounds") into tDescent2
>> 
>>  put the bottom of pField1 into tBot1
>>  put the bottom of pField2 into tBot2
>> 
>>  put tBot1 - fFormattedBottom1 + tDescent1 into tDiff1
>>  put tBot2 - fFormattedBottom2 + tDescent2 into tDiff2
>> 
>>  -- set the bottom of pField1 to tRef + tDiff1
>>  set the bottom of pField2 to tBot1 + tDiff2   
>> end alignFieldBaselines
>> 
>> 
>>> On Jun 21, 2018, at 10:09 , Bob Sneidar via use-livecode <use-livecode at lists.runrev.com> wrote:
>>> 
>>> Or better yet: (should probably be submitted to the Master Library). Trouble with this is that it relocates both fields. It should probably only move pField2. 
>>> 
>>> on alignFieldBaselines pField1, pField2
>>> local tDescent1, tDescent2, tBot1, tBot2, tDiff1, tDiff2, tRef
>>> local fFormattedBottom1, fFormattedBottom2
>>> 
>>> put 120 into tRef
>>> 
>>> put item 4 of the formattedRect of line 1 of pField1 into fFormattedBottom1
>>> put item 4 of the formattedRect of line 1 of pField2 into fFormattedBottom2
>>> 
>>> put item 4 of measureText(line 1 of pField1, pField1 ,"bounds") into tDescent1
>>> put item 4 measureText(line 1 of pField2, pField2 ,"bounds") into tDescent2
>>> 
>>> put the bottom of pField1 into tBot1
>>> put the bottom of pField2 into tBot2
>>> 
>>> put tBot1 - fFormattedBottom1 + tDescent1 into tDiff1
>>> put tBot2 - fFormattedBottom2 + tDescent2 into tDiff2
>>> 
>>> set the bottom of pField1 to tRef + tDiff1
>>> set the bottom of pField2 to tRef + tDiff2   
>>> end alignFieldBaselines
>>> 
>>> Bob S
>>> 
>>> 
>>>> On Jun 21, 2018, at 04:37 , Niggemann, Bernd via use-livecode <use-livecode at lists.runrev.com> wrote:
>>>> 
>>>> Hi Mary,
>>>> 
>>>> I suppose you want to center those fields around a common horizontal baseline.
>>>> 
>>>> You might try this if that is what you want. Should work with different fonts and sizes.
>>>> 
>>>> Two fields, one button.
>>>> 
>>>> Kind regards
>>>> Bernd
>>>> 
>>>> ----------------------------------------------------------
>>>> on mouseUp
>>>> local tDescent1, tDescent2, tBot1, tBot2, tDiff1, tDiff2, tRef
>>>> local fFormattedBottom1, fFormattedBottom2
>>>> 
>>>> put 120 into tRef
>>>> 
>>>> put item 4 of the formattedRect of line 1 of field 1 into fFormattedBottom1
>>>> put item 4 of the formattedRect of line 1 of field 2 into fFormattedBottom2
>>>> 
>>>> put item 4 of measureText(line 1 of field 1, field 1 ,"bounds") into tDescent1
>>>> put item 4 measureText(line 1 of field 2, field 2 ,"bounds") into tDescent2
>>>> 
>>>> put the bottom of field 1 into tBot1
>>>> put the bottom of field 2 into tBot2
>>>> 
>>>> put tBot1 - fFormattedBottom1 + tDescent1 into tDiff1
>>>> put tBot2 - fFormattedBottom2 + tDescent2 into tDiff2
>>>> 
>>>> set the bottom of field 1 to tRef + tDiff1
>>>> set the bottom of field 2 to tRef + tDiff2
>>>> end mouseUp
>>>> ----------------------------------------------------------
>>>> 
>>>> 
>>>> 
>>>> _______________________________________________
>>>> 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
>>> 
>>> 
>>> _______________________________________________
>>> 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
>> 
>> 
>> _______________________________________________
>> 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
> 
> 
> _______________________________________________
> 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