Help with putting specific text in specific places in a button
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Help with putting specific text in specific places in a button
Hey guys!
So, I'm making progress with my Sudoku app (which is super exciting!), and I'm not up to the hard part - putting in numbers. I want to have the ability to put numbers into cells, but also put in pencil markings (like this sort of thing: https://imgur.com/Df8SnO5). There's two types of pencil markings here - the ones in the corners/edges of the cell (1, 2, 3, 4, 5, 6) and the centre markings (7, 8, 9). I want to be able to put both types of markings into my app
To put it into some background though, I'm making this app for Android, and the way I have it set up now is that there's a 9x9 set of buttons in my stack. When you move the mouse over one (or in this case, your finger), it will highlight it. Tapping also lets you highlight the buttons. I have a way to make the cells put numbers in, but I don't know how I can make the text of the button be that specific when it comes to the position of the numbers? Does anyone have any recommendations on how to do it?
Thanks in advanced!
So, I'm making progress with my Sudoku app (which is super exciting!), and I'm not up to the hard part - putting in numbers. I want to have the ability to put numbers into cells, but also put in pencil markings (like this sort of thing: https://imgur.com/Df8SnO5). There's two types of pencil markings here - the ones in the corners/edges of the cell (1, 2, 3, 4, 5, 6) and the centre markings (7, 8, 9). I want to be able to put both types of markings into my app
To put it into some background though, I'm making this app for Android, and the way I have it set up now is that there's a 9x9 set of buttons in my stack. When you move the mouse over one (or in this case, your finger), it will highlight it. Tapping also lets you highlight the buttons. I have a way to make the cells put numbers in, but I don't know how I can make the text of the button be that specific when it comes to the position of the numbers? Does anyone have any recommendations on how to do it?
Thanks in advanced!
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
I uploaded your image here to help us all have a think about things.
Although, to be honest, I'm not sure what you mean about 'pencil markings.'
Re: Help with putting specific text in specific places in a button
Thanks richmond - that makes it easier to see!
So, with Sudoku, a common technique is to 'pencil mark' the squares where you think numbers could be - this helps you keep track of what can and can't go in places. Depending on a few things (preference, style of solving etc), some people will put their pencil marks along the corners/edges of the cells (like the 1, 2, 3, 4, 5 and 6 in the picture), some will put it in the centre (like the 7, 8 or 9), and some will use both. I'm trying to make something that will work for all sorts of sudoku solvers
So, with Sudoku, a common technique is to 'pencil mark' the squares where you think numbers could be - this helps you keep track of what can and can't go in places. Depending on a few things (preference, style of solving etc), some people will put their pencil marks along the corners/edges of the cells (like the 1, 2, 3, 4, 5 and 6 in the picture), some will put it in the centre (like the 7, 8 or 9), and some will use both. I'm trying to make something that will work for all sorts of sudoku solvers

-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
Well . . . here's a thought, which might be daft, but might work . . .
- -
My mother (89 years young) does the Sudoko thing in her newspaper every day: keeps her sharp as a new pin.
Could never understand the attraction myself . . .
----
Have a group consisting of 7 fields (I have called them f1 to f7).
Of course you can set the borders of the fields to 0, and then set the border of the group to,
say, 2, so you end up with what looks like a single field.

- -
My mother (89 years young) does the Sudoko thing in her newspaper every day: keeps her sharp as a new pin.
Could never understand the attraction myself . . .
----
Have a group consisting of 7 fields (I have called them f1 to f7).
Of course you can set the borders of the fields to 0, and then set the border of the group to,
say, 2, so you end up with what looks like a single field.
- Attachments
-
- Sooodoko.livecode.zip
- Here's the stack.
- (1021 Bytes) Downloaded 209 times
Re: Help with putting specific text in specific places in a button
Hi richmond
Thanks for the reply - it's not a bad idea! The only issue though is that sometimes pencil markings can be more than 6 digits, though that's pretty rare in my case.
The only other issue is that at the moment I've got it set up so that on mouse move, it checks for the name of the control under the mouse. If there's a group of fields in the way, then I won't have any way to track which cell the user is hovering over?
Thanks for the reply - it's not a bad idea! The only issue though is that sometimes pencil markings can be more than 6 digits, though that's pretty rare in my case.
The only other issue is that at the moment I've got it set up so that on mouse move, it checks for the name of the control under the mouse. If there's a group of fields in the way, then I won't have any way to track which cell the user is hovering over?
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
Have a bash with this:
-
-
- Attachments
-
- Sooodoko 2.livecode.zip
- Here's the stack.
- (1.24 KiB) Downloaded 214 times
Re: Help with putting specific text in specific places in a button
Hi richmond
That's a great idea! At the moment I have it based on mouse move with it checking the control beneath it to see if it's a valid control to do things with, but if I use mouse enter, that'll make it so much easier! And I could make a group with labels as you suggested, and then just use mouse enter on the groups?
I'll give it a shot tomorrow and see how it goes - hopefully it'll go well though!
That's a great idea! At the moment I have it based on mouse move with it checking the control beneath it to see if it's a valid control to do things with, but if I use mouse enter, that'll make it so much easier! And I could make a group with labels as you suggested, and then just use mouse enter on the groups?
I'll give it a shot tomorrow and see how it goes - hopefully it'll go well though!
Re: Help with putting specific text in specific places in a button
I would use "the target" instead of "me" when trying to see what control the cursor enters.
"Me" don't enter into it.
Craig
"Me" don't enter into it.
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
Can you explain why?I would use "the target" instead of "me" when trying to see what control the cursor enters.
Re: Help with putting specific text in specific places in a button
Richmond.
Sure.
Make a button and a field on a new card. In the card script:
Try both. "Me" don't enter into it.
Craig
Sure.
Make a button and a field on a new card. In the card script:
Code: Select all
on mouseEnter
-- put the name of me into fld 1
put the name of the target into fld 1
end mouseEnter
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
I must be missing something as both
and
work equally well for me.
-
Code: Select all
put the short name of me into fld "f1"
Code: Select all
put the short name of the target into fld "f1"
-
- Attachments
-
- Me.livecode.zip
- Here's the stack.
- (975 Bytes) Downloaded 205 times
Re: Help with putting specific text in specific places in a button
Hmmm.
In a "mouseEnter" handler? I do not see this at all.
I have a card with two fields and a button on it. In field 1 I have "XYZ". I set the contents of the button to "B1". In the card script:
What do you see when you navigate into each control with each controlKey held down? I get only a card reference with the commandKey, the only line that calls for "me". This is because a card is not a container, and will yield its name.
Craig
In a "mouseEnter" handler? I do not see this at all.
I have a card with two fields and a button on it. In field 1 I have "XYZ". I set the contents of the button to "B1". In the card script:
Code: Select all
on mouseEnter
if the optionKey is down then put the target into fld 2
if the commandKey is down then put me into fld 2
if the shiftKey is down then put the value of the target into fld 2
if the controlKey is down then put target into fld 2
end mouseEnter
Craig
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
Hmm . . . a right pain in the bum, frankly:-
- -
On a Macintosh
SHIFT empties the field
CONTROL puts the name into the field
ALT puts the name into the field
COMMAND empties the field
but, then, your script is inconsistent:
- -
On a Macintosh
SHIFT empties the field
CONTROL puts the name into the field
ALT puts the name into the field
COMMAND empties the field
but, then, your script is inconsistent:
Code: Select all
on mouseEnter
if the optionKey is down then put the target into fld 2
if the commandKey is down then put me into fld 2
if the shiftKey is down then put the value of the target into fld 2
if the controlKey is down then put target into fld 2
end mouseEnter
- Attachments
-
- Me too.livecode.zip
- Here's the stack.
- (1.08 KiB) Downloaded 212 times
-
- Livecode Opensource Backer
- Posts: 10099
- Joined: Fri Feb 19, 2010 10:17 am
Re: Help with putting specific text in specific places in a button
So . . .
- -
I now have 2 buttons: "Where's the beer?" and "Where's the cheese?"
with these scripts respectively:
and everything works . . . . 

- -
I now have 2 buttons: "Where's the beer?" and "Where's the cheese?"
with these scripts respectively:
Code: Select all
on mouseEnter
if the optionKey is down then put the target into fld "f1"
if the commandKey is down then put the target into fld "f1"
if the shiftKey is down then put the target into fld "f1"
if the controlKey is down then put the target into fld "f1"
end mouseEnter
Code: Select all
on mouseEnter
if the optionKey is down then put the name of me into fld "f1"
if the commandKey is down then put the name of me into fld "f1"
if the shiftKey is down then put the name of me into fld "f1"
if the controlKey is down then put the the name of me into fld "f1"
end mouseEnter

- Attachments
-
- Harvey Weinstein.livecode.zip
- Here's the stack.
- (1.17 KiB) Downloaded 205 times
Re: Help with putting specific text in specific places in a button
@richmond62: That's because you have attached those scripts to the button - buttons cannot contain controls so 'the target' is always the same as 'me'. You will see a difference if you put the scripts in an object containing the button (e.g. card, or group if the button is in a group). Then 'the target' will be the button, whereas 'me' will be the object you attached the script to. [ 'the target' is the control which received the event, even if the message passes up the owner-chain; 'me' is the control whose script contains the running handler. ]