Hi Brian, Panos showed me the already build-in solution!
Just use globalloc() and localloc() to translate to and from screencoordinates/card coordinates also on "Mobile"! Just tested and as far as I can tell this works a charme! :-) A typical "slap on the forehead" thingie... > Am 18.10.2022 um 17:25 schrieb Brian Milby via use-livecode > <[email protected]>: > > Klaus, > > My setBackground handler doesn't give a direct translation, but does start > it. > https://github.com/bwmilby/mobileDemo/blob/48b89b37aba41afb5a7b90cfc9bdbbca9e7f052c/mobileDemo_Scripts/stack_MobileDemo_card_id_1002.livecodescript#L105 > Since we are talking about portrait on mobile, the extra space will always > be in the height direction. That simplifies a few things. The height of > the screen from the card perspective will be: > put tCardW / (tScreenW / tScreenH) into tNewH > You will need 3 things to calculate positions. A ratio for each direction > and a height offset. > put (tNewH - tCardH) / 2 into tHOffset -- 1/2 of the extra pixels with > be at the top > put tNewH / tScreenH into tHRatio -- convert screen pixels to card pixels > put tCardW / tScreenW into tWRatio -- convert screen pixels to card > pixels > Using this, you should be able to calculate a card XY value from a screen > XY value (safe XY for example). > put (tScreenY * tHRatio) - tHOffset into tCardY > put (tScreenX * tWRatio) into tCardX > > This is without testing though. I'll try to do a test to validate my > method. And remember, that anything placed outside the bounds of the card > will just be there for looks and probably won't respond to touch. > > Thanks, > Brian Best Klaus -- Klaus Major https://www.major-k.de https://www.major-k.de/bass [email protected] _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
