Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Richard Gaskin via use-livecode

Mark Waddingham wrote:

> Whenever a range of text is set in a field, the selection is set to
> the beginning of the chunk that was set - so in the case of 'replace'
> acting on the whole field, that would be the beginning.
>
> Using the '(replacing | preserving) styles' form works slightly
> differently - it iterates through the content of the field, and only
> mutates the parts which are to be replaced. So with that form, the
> selection index would end up being the beginning of the last
> occurrence of x which was replaced with y.
>
> The rule is relatively sensible I think - since if a range of text is
> replaced, the only index you can guarantee will be in the same place
> as  it was before is the beginning of the range which was replaced...

Yes, quite sensible with that description.  Thanks.

> The textChanged message is a bit of a blunt instrument -  mainly
> because it was the best we could add to the field at the time
> without potentially ending up down a whole set of rabbit warrens, or
> impacting performance too much.

As I was writing my post I pondered what a proposed change might be, and 
I couldn't think of a good one.  Yes, it is a blunt instrument, but with 
that it's also predictable, and consistent with other text messages.


Maybe there's a better way, but frankly where I've used it in real-world 
projects I've found the textChanged message very useful as-is.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread hh via use-livecode
> Craig wrote:
> The textChanged handler sort of works. If you leave the field and replace the 
> cursor, the next char goes after the currently selected line. From then on it 
> goes before the current text.The backspace key does not really work.


Hey, of course it works. When editing it deletes one char at a time, when 
typing it deletes everything before the first char ;-)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Jonathan Lynch via use-livecode
Maybe share a sample stack when you get it worked out? This could be useful for 
users in places that use right-to-left text. We could with sticking points that 
way.

Sent from my iPhone

> On Sep 21, 2017, at 2:03 PM, Mark Waddingham via use-livecode 
>  wrote:
> 
> dominant

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Mark Waddingham via use-livecode

On 2017-09-21 19:48, Mark Waddingham via use-livecode wrote:



For example, let's say you have a right to left language FOO which has
letters A, B, C; compared to a left to right language BAR which has
letters X, Y and Z. Hello in FOO is spoken A-B-C; Hello in BAR is
spoken X-Y-Z. However, as FOO is right to left, Hello is written CBA.
If these languages were mixed in a single piece of text - spoken as
A-B-C X-Y-Z - then in memory the order would be ABC XYZ, but visually
it would appear as either:

  i) from the left edge - CBA XYZ

  ii) from the right edge - XYZ CBA

Whether it would be (i) or (ii) depends on which is considered to be
the dominant language in that case and context.




I should perhaps have mentioned the 'useful' outcome of the above 
tangent...


If text is always stored in memory in logical order (in the order we 
utter it / actually read the individual constituent parts), then 
processing of a string containing left-to-right text, or right-to-left 
text or any mixed combination there-of needs no more thought than 
processing a string which is composed of a language which is written 
left-to-right - because (logically - in terms of how humans process it 
themselves) there is no difference.


All apparent 'difficulties' and 'oddness' which dealing with non 
left-to-right text are confined solely to the presentation layer - which 
at the level of rendering text, LiveCode does for you.


This is important to remember if you are involved in localisation 
applications to languages such as Arabic - the main work you have to do 
is getting the translations in the first place, and *potentially* making 
your app right-to-left dominant, rather than left-to-right (i.e. labels 
should go on the right of fields, rather than the left, and things 
should generally be aligned to the right, rather than the to the left - 
although the actual alignment of text within fields  / buttons etc. will 
'do the right thing').


Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread dunbarx via use-livecode
Well, at least this explains it:\


"...essentially"

on textchanged 
  select before me 
end textchanged 



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread dunbarx via use-livecode
Well it just goes to show that I do need a computer. Mental scripting only
sounds, er, sound.

This works:

on keyDown, tKey 
   if the shiftkey is down and the capsLockKey is down then put tKey &
return before me 
   else put tKey before me
select before me
end keyDown

All the other "control" keys likely have their own functionality, and I did
not want to fiddle with them.

The textChanged handler sort of works. If you leave the field and replace
the cursor, the next char goes after the currently selected line. From then
on it goes before the current text.The backspace key does not really work.

But now we come to the real question. 

Ahem.

How does the textChanged handler work at all



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Mark Waddingham via use-livecode

On 2017-09-21 18:48, Richard Gaskin via use-livecode wrote:

Indeed it does.  At first glance the behavior seems at least
unintuitive.  It also appears to prevent the Backspace key from having
any effect.  Is it a bug?  A feature?

Hmmm...

On further consideration it may make sense, since the selection is
removed by replacing the field contents, and the default selection is
at the beginning of a line.


Indeed!

When you do 'replace x with y in ' then the engine:

  1) Fetches the text of the field as a string

  2) Performs replace x with y on that string

  3) Sets the text of the field to the modified string

Whenever a range of text is set in a field, the selection is set to the 
beginning of the chunk that was set - so in the case of 'replace' acting 
on the whole field, that would be the beginning.


Using the '(replacing | preserving) styles' form works slightly 
differently - it iterates through the content of the field, and only 
mutates the parts which are to be replaced. So with that form, the 
selection index would end up being the beginning of the last occurrence 
of x which was replaced with y.


The rule is relatively sensible I think - since if a range of text is 
replaced, the only index you can guarantee will be in the same place as 
it was before is the beginning of the range which was replaced...


Although it does give a somewhat amusing outcome in this case :)


It would seem the only way to preserve the insertion point would be to
separately trap for all relevant messages (backspaceKey, pasteKey,
dragDrop, keyDown, etc.), where you first query the selectedChunk,
perform the action, then adjust the selectedChunk according to the
length of the operation, and then restore the insertion point at the
adjusted offset.


Yes - I can't think of an alternative approach at the moment which would 
be easier. The textChanged message is a bit of a blunt instrument - 
mainly because it was the best we could add to the field at the time 
without potentially ending up down a whole set of rabbit warrens, or 
impacting performance too much.



This seems like so many things in a good scripting language:  when you
want to do something ordinary, the provided behaviors make the task
uncommonly easy.  But when you want to do something extraordinary, the
task is uncommonly difficult.


Of course one question to ask here is - what are the use cases where you 
need to preserve the selection index where the 'set it to the beginning 
of the last replaced chunk' isn't appropriate? If script is doing the 
mutation, then it can happily save / restore the index itself - so it 
would come down to user-interaction cases - finding out about those 
would probably help pin down what the field could do to make things 
easier.




Incidentally whilst the above has the effect of writing bottom to top / 
right to left it is only a superficial effect as the order of the chars 
ends up being 'the wrong way round' in the internal string. Regardless 
of the writing system, humans still (I believe at least...) always 
process language in spoken order, which is the same as the order we read 
in - the fact some languages are right to left, bottom to top, right to 
left to right to left etc. is 'merely' a presentation / visual thing.


For example, let's say you have a right to left language FOO which has 
letters A, B, C; compared to a left to right language BAR which has 
letters X, Y and Z. Hello in FOO is spoken A-B-C; Hello in BAR is spoken 
X-Y-Z. However, as FOO is right to left, Hello is written CBA. If these 
languages were mixed in a single piece of text - spoken as A-B-C X-Y-Z - 
then in memory the order would be ABC XYZ, but visually it would appear 
as either:


  i) from the left edge - CBA XYZ

  ii) from the right edge - XYZ CBA

Whether it would be (i) or (ii) depends on which is considered to be the 
dominant language in that case and context.




Warmest Regards,

Mark.

--
Mark Waddingham ~ m...@livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread hh via use-livecode
Of course it is essentially:

on textchanged
  select before me
end textchanged

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread hh via use-livecode
> R.G. wrote
> Indeed it does. At first glance the behavior seems at least 
> unintuitive. It also appears to prevent the Backspace key from having 
> any effect. Is it a bug?  A feature?

You can also edit one char at a time.

Isn't that a feature for right to left languages?
One has simply to work a little bit harder to do the right to left top to down.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Richard Gaskin via use-livecode

hh wrote:


> hh wrote:
> on textChanged
>  replace space with space in me -- or whatever
> end textChanged
Bob S. wrote:
Whut? All that will do is replace spaces with spaces. That will not reverse the order of the typed text. 


(Instead of "space" use also any other char, for example "cr")
It works. Just try. 


Indeed it does.  At first glance the behavior seems at least 
unintuitive.  It also appears to prevent the Backspace key from having 
any effect.  Is it a bug?  A feature?


Hmmm...

On further consideration it may make sense, since the selection is 
removed by replacing the field contents, and the default selection is at 
the beginning of a line.


It would seem the only way to preserve the insertion point would be to 
separately trap for all relevant messages (backspaceKey, pasteKey, 
dragDrop, keyDown, etc.), where you first query the selectedChunk, 
perform the action, then adjust the selectedChunk according to the 
length of the operation, and then restore the insertion point at the 
adjusted offset.


This seems like so many things in a good scripting language:  when you 
want to do something ordinary, the provided behaviors make the task 
uncommonly easy.  But when you want to do something extraordinary, the 
task is uncommonly difficult.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread hh via use-livecode
> > hh wrote:
> > on textChanged
> >  replace space with space in me -- or whatever
> > end textChanged
> Bob S. wrote:
> Whut? All that will do is replace spaces with spaces. That will not reverse 
> the order of the typed text. 

(Instead of "space" use also any other char, for example "cr")
It works. Just try. 



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread Bob Sneidar via use-livecode
Whut? All that will do is replace spaces with spaces. That will not reverse the 
order of the typed text. 

Bob S


> On Sep 21, 2017, at 03:00 , hh via use-livecode 
>  wrote:
> 
> on textChanged
>  replace space with space in me -- or whatever
> end textChanged


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: How to to type bottom to up and right to left in a field

2017-09-21 Thread dunbarx via use-livecode
Hi.

Not sure at all what that handler does. But something like this, off the top
of my head:

on keyDown, tKey
   if the optionKey is down then put return & tKey before me
   else put tKey before me
end keyDown

Craig Newman



--
Sent from: 
http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


How to to type bottom to up and right to left in a field

2017-09-21 Thread hh via use-livecode
Because "textChanged" was also mentioned in a recent thread.
This is a handler full of features:

*** How to to type bottom to up and right to left in a field ***

Simply script the field as follows and start typing.

on textChanged
  replace space with space in me -- or whatever
end textChanged

Doesn't work, of course, with pasted text or insertions by script.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode