PDA

View Full Version : Just obe little question I need help with if you can


bobbie
03-12-2006, 12:41 PM
I have a little project I did and all seems to work find but someone ask me if when you highlight the word the word would be in the code ?
like this [ B ]Fat[ /B ] (space it so it would show up)
Input.SetText("Input1", "");
text = Input.GetText("Input1");
Clipboard.CopyText(text);
So any word put in to the input1 would then have the bbcode around it when highlighted . right now if you add a word it will get over written .

Oh the text is coming from the name of the button.

bobbie
03-12-2006, 01:51 PM
Anyone know how to do this?
Like to give out the new one with the fix.

Corey
03-12-2006, 01:54 PM
I'm not sure I understand the specific question.

bobbie
03-12-2006, 01:58 PM
Well if you look at where you post here you see all the bbcodes just about the post area.
If you click and drag on a word then click one of the icons about the post it will add the bbcode to the word.
I want to do the samething with the words in the inputbox.

Corey
03-12-2006, 02:25 PM
OK here's a very basic example, no error checking, etc. If you want to make it account for line breaks, etc. then check into the 3rd parameter of Input.GetSelection "Linenum". All code is on the button's "On Click" event. If the code seems complicated just break it down bit by bit, the concept is that we get the selection start and end points and then get the input text, then simply apply string formatting accordingly. :yes

Corey
03-12-2006, 02:26 PM
FYI Just updated the attachment with multiple buttons. :yes

bobbie
03-12-2006, 02:28 PM
Ok thank you .. going to check it out now.

Thank you .. just what I wanted..

Corey
03-12-2006, 02:30 PM
Bear in mind this isn't the most elegant way to do it, it's just a crude example to illustrate the concept. It's pretty easy to adapt to a function though, which is the best approach with any code that you will be using more than once within your project such as this. So that would be the way to go. :yes

bobbie
03-12-2006, 02:40 PM
When I try to add the copy to clipboard it gives an error ?
Clipboard.CopyText(Mytext);

---------------------------
Error
---------------------------
On Click, Line 4: Argument 1 must be a string.
---------------------------
OK
---------------------------
mySelection = Input.GetSelection("Input1");
myText = Input.GetText("Input1");
Input.SetText("Input1", String.Left(myText, mySelection.Start - 1)..""..String.Mid(myText, mySelection.Start, (mySelection.End - mySelection.Start) + 1)..""..String.Right(myText, (String.Length(myText) - mySelection.End)));
Clipboard.CopyText(Mytext);

Corey
03-12-2006, 02:42 PM
You mistyped the variable name. Always double check that first in the case of an error. :yes

bobbie
03-12-2006, 02:53 PM
I see that now . lol
myText
How can I add a msg if they don't select the word?


---------------------------
Error
---------------------------
On Click, Line 3: attempt to index global `mySelection' (a nil value)
---------------------------
OK
---------------------------

bobbie
03-12-2006, 03:29 PM
One more thing. it is not copying the bbcode part just the word that is type in the input box?

Corey
03-12-2006, 04:05 PM
Not sure, you'll have to check it and fix it and experiment to meet your needs, as I said in my earlier post, there is no error checking, etc.

bobbie
03-12-2006, 04:23 PM
Guess thats as far as I go with this then.

Corey
03-12-2006, 04:35 PM
I wouldn't give up so easy. Get in there and read the code, then try and code the features you desire. If you have a specific problem with your code, post it someone will help fix it. A little effort goes a long way on something as simple as this. FWIW the examples I post are intended solely to help you learn how to code the features yourself. The idea being that if you have some working code to start with, you can chop it up and figure out the variation which works best for your actual project. :yes