text focus works differently on mac and windows

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

text focus works differently on mac and windows

Post by Lagi Pittas » Sat Mar 04, 2017 10:39 pm

Hi

I have a set of buttons which increase a number in a set of textfields. The textfields are set to locktext, traversalon and showfoucus - on Mac when I click any of the textboxes i see a blue border to show the textbox has focus
and when I click one of the buttons I execute the code

Code: Select all

put the name of the focusedobject into lcBox
if the name of the focusedobject contains "txt" then
  add the label of me to field lcBox
else
  beep
end if
This works perfectly on the Mac on which the program has been developed, but on windows I get the beep.
It seems the focusedobject becomes the button I just pressed. I'd just like to know why this is the case - to be honest
the window way of working makes more sense but I thought I was given a freeplay when the code worked without any extra code on the Mac.

Kindest Regards lagi

Lagi Pittas
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 366
Joined: Mon Jun 10, 2013 1:32 pm

Re: text focus works differently on mac and windows

Post by Lagi Pittas » Mon Mar 06, 2017 12:21 pm

Hi

My question was not about how to do "fix" the problem that had found when I tried to run the program on the Mac - it took longer
to post to the forum than fix it. My question is whether this is a Livecode anomaly (I'm using 6.7.11) or whether it's the way the Mac works.

I can see this can affect other stuff in the future if they have to work on both Mac and Windows and forewarned is forearmed so to speak.

In the meantime I know this is Livecode 101 but the fix is trivial especially when using custom properties of a group - no dreaded Globals.
So here it is ...

I grouped the text field that would be increased by the label of the buttons (labels are -1, +1, -5 , +5, 10-, +10 etc).
and added this code top the group

Group "grpPercentVal" script

Code: Select all

on MouseUp

Regards Lagi
   set the uLastPressed  of me to the short name of the target
   put the uLastPressed of me
end MouseUp
And in the button group that the user would press to increase or decrease the percentage value I added

Group "grpIncDec" script

Code: Select all

on Mouseup
   local lcField, lnVal
   put the uLastPressed of group "grpPercentVal" into lcField
   -- Default to the first if they haven't pressed any one
   if lcField is empty then
      put "txtP1" into lcField
   end if
   put field lcField into lnVal
   add the label of the target to lnVal
   put lnVal into field lcField
end Mouseup

Post Reply