Some Newbie-Problems with text and clicks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Some Newbie-Problems with text and clicks
I am programmer with quite some experience in traditional programming languages. Revolution Transcript however is completely new to me and I need some time getting used to it - since I have to use it in a new project. And it seems to be quite powerful but not as nice and pure as what I normally use...
Anyway: My problem seems very simple - and I am sure there is a simple solution. Which I just don't find wherever I look for it.
I am building some kind of translator. I have a textfield with a text in it. When I click on any word in the text the clicked word changes color als long as I hold the mouse button. I know how to do that... but:
Problem 1: There seems to be some kind of bug in RunRev - because sometimes only parts of the word (f.e. only the lower half of the characters) is colored, leaving the rest in black - and sometimes after recoloring the word to black, some pixel of the word still remain red. Does anybody know about this problem and if there is a workaround?
Problem 2 (and this might be just a stupid question): How can I retrieve the position of the clicked word in the text? Like when I am clicking on word number 47 - how do I get this number 47? I only find explanations for the other way. No problem to hilite word number 47 - but when clicking, is there a function to retrieve the word number (or maybe first char number would be fine as well) of the clickedChunk? I just gave up searching for this - but I have the very strong feeling that there must be a simple solution.
I appreciate any hint or help. Thank you very much!
Anyway: My problem seems very simple - and I am sure there is a simple solution. Which I just don't find wherever I look for it.
I am building some kind of translator. I have a textfield with a text in it. When I click on any word in the text the clicked word changes color als long as I hold the mouse button. I know how to do that... but:
Problem 1: There seems to be some kind of bug in RunRev - because sometimes only parts of the word (f.e. only the lower half of the characters) is colored, leaving the rest in black - and sometimes after recoloring the word to black, some pixel of the word still remain red. Does anybody know about this problem and if there is a workaround?
Problem 2 (and this might be just a stupid question): How can I retrieve the position of the clicked word in the text? Like when I am clicking on word number 47 - how do I get this number 47? I only find explanations for the other way. No problem to hilite word number 47 - but when clicking, is there a function to retrieve the word number (or maybe first char number would be fine as well) of the clickedChunk? I just gave up searching for this - but I have the very strong feeling that there must be a simple solution.
I appreciate any hint or help. Thank you very much!
"irgendwas is immer"
2. clickchunk
1. I don't know, it depends on how you did the colour changes, depending on the way you did it, there can be many problems, most caused by your code, not by rev...
I would suggest to set the textstyle to link, and use the linktext for actions you want to make. You can control the colour of all links with the linkcolor property.

1. I don't know, it depends on how you did the colour changes, depending on the way you did it, there can be many problems, most caused by your code, not by rev...
I would suggest to set the textstyle to link, and use the linktext for actions you want to make. You can control the colour of all links with the linkcolor property.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Thanks, but...
... of course I know clickChunk and I use it in my code. But clickChunk seems to be just the reference to the chunk itself. How do get a number out of this clickChunk function? I don't need the chunk itself but the position of the chunk in the whole text as an integer number. I need to know that the user clicked on word number 35 or maybe char number 147-155. So I can link it to my database which has a translation for each word in the order of the text (the same word can have different translations if it appears in different parts of the text).
The other problem:
A simple example:
In Browse-Mode this seems ok - in Windows. But in the compiled version (and in Browse Mode in MacOSX) some pixels of some characters don't get colored so that sometimes the upper half of some word is black and the lower half is red. I've seen similar problems with selecting text in another script: The selection sometimes didn't have the same height as the text it was covering so that it only covered half the text. If this is not a bug... what else could it be???
Thank you for the advice with the linktext. It seems a bit unnecessary complicated - but if it works... it would be fine...
Grateful for advice!
The other problem:
This sounds like a general wisdom well known to most of us. But in this specific case I am quite sure that this is a bug in runrev... and I am afraid there are some of them in it which makes the decision to use it for a huge project even more difficult...1. I don't know, it depends on how you did the colour changes, depending on the way you did it, there can be many problems, most caused by your code, not by rev...
A simple example:
Code: Select all
on mouseDown
set textColor of clickchunk() to "red"
end mouseDown
Thank you for the advice with the linktext. It seems a bit unnecessary complicated - but if it works... it would be fine...
Grateful for advice!
"irgendwas is immer"
Kroka,
Once you know the clickChunk, you can calculate the number of words between char 1 of a field and the clickChunk.
Best,
Mark
Once you know the clickChunk, you can calculate the number of words between char 1 of a field and the clickChunk.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hmmm...
Thank you, Mark. But how?
This doesn't work. How is clickChunk used to specify the end of a range? I tried a lot of things... but no success...
Sorry for bothering.
Kroka
Code: Select all
get the number of chars of (char 1 to the clickchunk of the field "textfeld")
Sorry for bothering.
Kroka
"irgendwas is immer"
Kroka,
If you look closely at the clickChunk, you see that it contains two numbers. The number of words of (char 1 to <one of these numbers> of field <the name of your field>) gives what you want. Don't forget the brackets.
Mark
If you look closely at the clickChunk, you see that it contains two numbers. The number of words of (char 1 to <one of these numbers> of field <the name of your field>) gives what you want. Don't forget the brackets.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Thanks, but...
the clickChunk generates something like this:kroka wrote:...I need to know that the user clicked on word number 35 or maybe char number 147-155...
char 259 to 264 of field 1
How is that not exactly what you want? I don't get it, sorry.
Code: Select all
on mouseDown
set the textColor of the clickchunk to "red"
end mouseDown
Although it is indeed a bug in Rev, it's not really something that is gonna change soon. Most users won't even notice it.
Also note that using the link/linktext/linkclicked approach won't help you in this regard.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Thank you! It works. Now I understood the thing about the clickChunk and that it delivers a string expression instead of a referenceable parameter list. I am still not used to this concept since I am programming in C++ otherwise and this is my first encounter with the runrev concept. The idea of Revoution Studio itself I find amazing in many ways - but it demands a totally different way of thinking if you haven't grown up with hypercard.
This little bug worries me a bit more. It was (by coincidence) the very first thing I tried with my evaluation version of Revolution Studio - and coloring text by clicking it is to be one of the fundamentals of the whole project I am starting right now. So I was a bit surprised that my first experience turned out to be a bug in the system - and nothing I can do about that.
I agree that most people won't even notice - apart from those who write a program like mine. Or the users of my program.
But I think you would agree that a program where colored text is not clean because some pixels are not colored - or red pixels remain after deselecting - looks a bit faulty and unprofessional. So I hope this is the only visible bug... and that there is some kind of workaround (like refreshing the field without flickering).
Thank you both again and sorry for asking stupid questions.
Kroka
This little bug worries me a bit more. It was (by coincidence) the very first thing I tried with my evaluation version of Revolution Studio - and coloring text by clicking it is to be one of the fundamentals of the whole project I am starting right now. So I was a bit surprised that my first experience turned out to be a bug in the system - and nothing I can do about that.
I agree that most people won't even notice - apart from those who write a program like mine. Or the users of my program.
But I think you would agree that a program where colored text is not clean because some pixels are not colored - or red pixels remain after deselecting - looks a bit faulty and unprofessional. So I hope this is the only visible bug... and that there is some kind of workaround (like refreshing the field without flickering).
Thank you both again and sorry for asking stupid questions.
Kroka
"irgendwas is immer"
In rev everthing is a string. Whatever you try, you can always just use the message box to output the result as a string. only arrays are a bit different, as there is no single command to show them as strings.kroka wrote:Thank you! It works. Now I understood the thing about the clickChunk and that it delivers a string expression instead of a referenceable parameter list. I am still not used to this concept since I am programming in C++ otherwise and this is my first encounter with the runrev concept.
No. I meant users that use a program that sometimes has one pixel wide parts of the text wrongly coloured won't notice, not just any group of users.kroka wrote:...So I was a bit surprised that my first experience turned out to be a bug in the system - and nothing I can do about that.
I agree that most people won't even notice - apart from those who write a program like mine. Or the users of my program...
also:
Code: Select all
set the textcolor of the clickchunk to "red"
go this card
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode