get the selectedChunk
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 12
- Joined: Sun Apr 16, 2006 4:52 am
get the selectedChunk
I would like to get the selectedChunk from a palette.
If I put the button on the same card as the field then the handler
on mouseUp
answer the selectedChunk
end mouseUp
works.
If I do the same thing with a button on a palette then I get an empty answer. Though with
on mouseUp
select before fld "AAA" of stack "xyxy"
answer the selectedChunk
end mouseUp
the answer is correct.
Is there a way to get the position of the cursor/selection from a palette?
Till
EDIT:
OP: MacOS Sierra, 10.12.4
LC Version is 9.0.0-dp-6
If I put the button on the same card as the field then the handler
on mouseUp
answer the selectedChunk
end mouseUp
works.
If I do the same thing with a button on a palette then I get an empty answer. Though with
on mouseUp
select before fld "AAA" of stack "xyxy"
answer the selectedChunk
end mouseUp
the answer is correct.
Is there a way to get the position of the cursor/selection from a palette?
Till
EDIT:
OP: MacOS Sierra, 10.12.4
LC Version is 9.0.0-dp-6
Re: get the selectedChunk
Hi Till,
maybe setting the defaultstack first will do?
I think your second script does exactly this, so it works.
Best
Klaus
maybe setting the defaultstack first will do?
Code: Select all
...
set the defaultstack to "xyz"
answer the selectedchunk
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9644
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: get the selectedChunk
Hi.
Should work just fine. as simply as you wrote it.
A palette floats above other stacks, but "sees" those stacks as if it was part of them. You could even have two stacks, either with text selected, and a palette stack, (even if a substack of one of them) would still return the chunk requested. Assuming you had two stacks named "untitled 1" and "untitled 2", each with a field with some random text in it, in a button script on the palette:
So tell us exactly how you constructed your stack and palette.
Craig Newman
Should work just fine. as simply as you wrote it.
A palette floats above other stacks, but "sees" those stacks as if it was part of them. You could even have two stacks, either with text selected, and a palette stack, (even if a substack of one of them) would still return the chunk requested. Assuming you had two stacks named "untitled 1" and "untitled 2", each with a field with some random text in it, in a button script on the palette:
Code: Select all
on mouseUp
select word 1 of fld 1 of stack ("untitled" && random(2))
answer the selectedChunk
end mouseUp
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 12
- Joined: Sun Apr 16, 2006 4:52 am
Re: get the selectedChunk
I guess I was not able to explain my problem
The Script I put here
on mouseUp
select before word 1 of fld 1 of stack xyxy
answer the selectedChunk
end mouseUp
means, that I have to know where the cursor is. But that is not the case. I would like to push the button on the palette (it could also be on a normal stack) and would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty). With this information I would like to change for instance the list indent.
If I select a word in that field then the handler in the palette
on mouseUp
answer the selectedChunk
end mouseUp
will give me the information I am looking for → char 16 to 18 of fld 1. The cursor blinking in a field seems to not be the same as a selected word when I call it with the selectedChunk.
Is there any other was how I can get the information I am looking for?
Thanks, Till
The Script I put here
on mouseUp
select before word 1 of fld 1 of stack xyxy
answer the selectedChunk
end mouseUp
means, that I have to know where the cursor is. But that is not the case. I would like to push the button on the palette (it could also be on a normal stack) and would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty). With this information I would like to change for instance the list indent.
If I select a word in that field then the handler in the palette
on mouseUp
answer the selectedChunk
end mouseUp
will give me the information I am looking for → char 16 to 18 of fld 1. The cursor blinking in a field seems to not be the same as a selected word when I call it with the selectedChunk.
Is there any other was how I can get the information I am looking for?
Thanks, Till
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: get the selectedChunk
What value do you see returned from "the selectedChunk" when the cursor is inserted into the field but no words are selected?Till Bandi wrote:I guess I was not able to explain my problem
The Script I put here
on mouseUp
select before word 1 of fld 1 of stack xyxy
answer the selectedChunk
end mouseUp
means, that I have to know where the cursor is. But that is not the case. I would like to push the button on the palette (it could also be on a normal stack) and would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty). With this information I would like to change for instance the list indent.
If I select a word in that field then the handler in the palette
on mouseUp
answer the selectedChunk
end mouseUp
will give me the information I am looking for → char 16 to 18 of fld 1. The cursor blinking in a field seems to not be the same as a selected word when I call it with the selectedChunk.
Is there any other was how I can get the information I am looking for?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: get the selectedChunk
Hi richard,
as he wrote earlier: EMPTY!
Just made a quick test with a toplevel stack with a field and a plalette stack with the button "put the selectedchunk":
1. Selected a word in the field -> char 1 to 5 of fld 1
2. NOTHING selected, but cursor in the field -> EMPTY/NADA/NOTHING
I think this is correct behavior since in 2. the field simply loses focus so there is no selectedchunk anymore!
However the selection/selected word as in 1. STAYS of course selected even if the field loses focus.
Best
Klaus
as he wrote earlier: EMPTY!
Just made a quick test with a toplevel stack with a field and a plalette stack with the button "put the selectedchunk":
1. Selected a word in the field -> char 1 to 5 of fld 1
2. NOTHING selected, but cursor in the field -> EMPTY/NADA/NOTHING
I think this is correct behavior since in 2. the field simply loses focus so there is no selectedchunk anymore!
However the selection/selected word as in 1. STAYS of course selected even if the field loses focus.
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: get the selectedChunk
Klaus, I always enjoy your exclamation marks, but what he wrote was:
That was what prompted me to write. As originally written, I'm unable to reproduce that. Seemed worth double-checking, since that's the sort of thing others would likely have seen as well, so it seems unlikely to have survived testing.
If the other script that doesn't explicitly set the selection is losing focus, then don't do that: set the button's traversalOn property to false and clicking it should no longer affect focus anywhere else.
That script should be impervious to any triggering action initially losing focus, because of course it re-establishes focus in the first statement.on mouseUp
select before word 1 of fld 1 of stack xyxy
answer the selectedChunk
end mouseUp
That was what prompted me to write. As originally written, I'm unable to reproduce that. Seemed worth double-checking, since that's the sort of thing others would likely have seen as well, so it seems unlikely to have survived testing.
If the other script that doesn't explicitly set the selection is losing focus, then don't do that: set the button's traversalOn property to false and clicking it should no longer affect focus anywhere else.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- VIP Livecode Opensource Backer
- Posts: 12
- Joined: Sun Apr 16, 2006 4:52 am
Re: get the selectedChunk
the traversalOn was already off when I originally asked my question. I tried now again with the traversalOn true and false, there is no difference, both give me an empty result.
Till
Till
Re: get the selectedChunk
Hi Richard,
...
would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty)
...
Same result in my test!!! and !!!
Best
Klaus
yes, and in the next line after that script he wrote:FourthWorld wrote:Klaus, I always enjoy your exclamation marks, but what he wrote was:...on mouseUp
select before word 1 of fld 1 of stack xyxy
answer the selectedChunk
end mouseUp
...
would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty)
...
Same result in my test!!! and !!!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9823
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: get the selectedChunk
I saw that, which is why I replied. If it was working there would be no need to investigate this further.Klaus wrote:yes, and in the next line after that script he wrote:
...
would like to get the answer where the cursor is (which line of which field of which stack – but the answer is empty)
The question at hand is: why is it not working?
Curious indeed. Here the script works as expected, and while I'm likely using a different OS (Ubuntu here), the logic of the statements should yield success.Same result in my test!!!
So this would appear to be a platform-specific bug, no?
Did I miss where the OP noted his OS and LC versions? Those may be useful to help pin this down.
Thank you!!!!!!!and !!!
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: get the selectedChunk
Hi Richard,
Best
Klaus
yep, looks like that.FourthWorld wrote:So this would appear to be a platform-specific bug, no?
No, Till didn't mention it.Did I miss where the OP noted his OS and LC versions?
Good boy!FourthWorld wrote:Thank you!!!!!!!and !!!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 12
- Joined: Sun Apr 16, 2006 4:52 am
Re: get the selectedChunk
OP: MacOS Sierra, 10.12.4
LC Version is 9.0.0-dp-6
(but I had this problem already in earlier versions).
I am not so familiar with Emojis: What means in this context "and !!! " ?
LC Version is 9.0.0-dp-6
(but I had this problem already in earlier versions).
I am not so familiar with Emojis: What means in this context "and !!! " ?
Re: get the selectedChunk
Hi Till,
that was just a personal joke by teasing Richard a bit:
Best
Klaus
that was just a personal joke by teasing Richard a bit:
FourthWorld wrote:Klaus, I always enjoy your exclamation marks, but...
Get it?Klaus wrote:...Same result in my test!!! and !!!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9644
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: get the selectedChunk
The emoji is used when one makes a point, possibly quite pointedly, but also wants to communicate that there is no (or very little) impatience, frustration or admonition involved.
To do any of the above, though still without rancor, one would use either or .
For rancor,
For worse yet: What the $^#%^$^%%...
Craig Newman
To do any of the above, though still without rancor, one would use either or .
For rancor,
For worse yet: What the $^#%^$^%%...
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 12
- Joined: Sun Apr 16, 2006 4:52 am
Re: get the selectedChunk
>> Get it?
>>The emoji is used when one makes a point, ...
yes and thanks
But there seems not to be a solution to my question how I can get the location of the cursor (Stack, card, field) with the selectedChink from a palette? Is there any other way to get this information?
>>The emoji is used when one makes a point, ...
yes and thanks
But there seems not to be a solution to my question how I can get the location of the cursor (Stack, card, field) with the selectedChink from a palette? Is there any other way to get this information?