Announcement

Collapse
No announcement yet.

Input.GetText from Input object to Italics in RichText object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Input.GetText from Input object to Italics in RichText object

    Hi,

    I really hope someone will be able to assist. I want to get the text that is typed into an Input object to be copied over into a RichText Object.

    The PROBLEM I have is that I want the text that is Italics in the Input object to be copied as Italics into the RichText object. I just can't get it to copy the Italics font.

    The Coding I have worked so far when I assign it to a button to get the text.

    InText1 = Input.GetText("Input1");
    AllText = InText1..".";
    RichText.SetText("RichText1", AllText, false);

    Any assistance will be appreciated.

    Willie Bouwer


  • #2
    Hi and Welcome to the forum
    Try this also code and I've included example

    Code:
    InText1 = Input.GetText("Input1");
    AllText = InText1..".";
    RichText.SetText("RichText1", AllText, false);
    tbFormatt = {Italic=true};
    RichText.SetSelection("RichText1", 1, -1);
    RichText.SetSelectionFormat("RichText1", tbFormatt, true);
    Page.SetFocus("Input1");
    RichText Italic.apz
    Cheers

    Comment


    • #3
      Dear colc,

      THANK YOU!! It works fantastic. Now one last question, but let me first explain:

      Let's say I have 5 input objects and I want input object # 3 to be Italic and the rest normal text. What I'm trying to achieve is built a string of text with only part of it in Italics, i.e.
      Smith, J. (2009). Higher education in South Africa: A scholarly look behind the scenes. The Journal of Higher Education. 6 (1), 183-202.

      My coding looks like this:

      InText1 = Input.GetText("Input1");
      InText2 = Input.GetText("Input2");
      InText3 = Input.GetText("Input3");
      InText4 = Input.GetText("Input4");
      InText5 = Input.GetText("Input5");
      InText6 = Input.GetText("Input6");
      InText7 = Input.GetText("Input7");
      InText8 = Input.GetText("Input8");
      AllText = InText1..". "..InText2..". "..InText3..". "..InText4..". "..InText5.."("..InText6.."): "..InText7..". "..InText8..".";
      RichText.SetText("RichText1", AllText, false);

      Your coding added:

      tbFormatt = {Italic=true};
      RichText.SetSelection("RichText1", 1, -1);
      RichText.SetSelectionFormat("RichText1", tbFormatt, true);
      Page.SetFocus("Input2");

      Now it makes it Italics (which is great) but it makes everything Italics. Would it be possible to limit it to just one Input?

      THANK YOU SO MUCH! I can't tell you how much I appreciate your help.

      Willie

      Comment


      • #4
        Sorry, the reference was supposed to show the part that is in Italics.

        Smith, J. (2009). Higher education in South Africa: A scholarly look behind the scenes. The Journal of Higher Education. 6 (1), 183-202

        Comment


        • #5
          Code:
          tblInputProps = {};
          tblInputProps.Text = "The Journal of Higher Education";
          tblInputProps.FontItalic = true;
          Input.SetProperties("Input6", tblInputProps);

          Comment


          • #6
            Originally posted by herrin View Post
            Code:
            tblInputProps = {};
            tblInputProps.Text = "The Journal of Higher Education";
            tblInputProps.FontItalic = true;
            Input.SetProperties("Input6", tblInputProps);
            Thank you herrin, unfortunately, it only seems to change the words in the Input object to Italics. It does not change anything in the RichText object where all the text is copied to.

            The idea is to change only that part of the text that is copied to the RichText object to Italics while the rest stays normal text.

            Comment


            • #7
              OK Willie, This is rather tricky as it requires a bit of maths
              With our select code RichText.SetSelection("RichText1", 1, -1); we have to set our start and end characters
              I have fiddled with this example and have not optimized or added error checking, it's just an example to get you going.
              So you have to count all the characters in the Inputs plus allow 1 for space between Inputs then get the start number then the length of the Input
              that is Italic - Then set SetSelection to those figures

              RichText Italic2.apz
              Cheers

              Comment


              • #8
                Originally posted by colc View Post
                OK Willie, This is rather tricky as it requires a bit of maths
                With our select code RichText.SetSelection("RichText1", 1, -1); we have to set our start and end characters
                I have fiddled with this example and have not optimized or added error checking, it's just an example to get you going.
                So you have to count all the characters in the Inputs plus allow 1 for space between Inputs then get the start number then the length of the Input
                that is Italic - Then set SetSelection to those figures

                [ATTACH]n305026[/ATTACH]
                Cheers
                Dear colc,

                THANK YOU! It works - you are a genius! Apologies for only replying now - I am on South Africa time. I'm trying to create an app for our students that work from home due to the COVID-19 pandemic. Many of them are stuck in rural areas and have limited resources (Internet, need to share computers with family, etc). So I'm trying to build a Harvard Generator tool to help them reference their essays and so on without them having to go on the internet because data is quite expensive on this side of the world.

                What you have given us so far really makes a big difference, so thank you!

                I've run the sample you have given us and two things that is unclear to me (I have very limited coding experience as I'm just an over-enthusiastic teacher).

                1 - This "Notice" box nr 1 pops up.

                2 - There are numbers indicating the amount of text in the Input Box. I don't mind these.

                But I am concerned that the pop up 'Notice' may confuse the kids. Is there possibly a way around it?

                Click image for larger version

Name:	01.png
Views:	209
Size:	18.9 KB
ID:	305030

                When the copy button is clicked the result is what we want!


                Click image for larger version

Name:	02.png
Views:	114
Size:	16.8 KB
ID:	305031

                Again, thank you so much for your time and effort. It is really appreciated on this side of the world.

                Kind wishes,

                Willie Bouwer
                ​​​​​​​

                Comment


                • #9
                  Hi colc,

                  I have set the visibility attribute for the labels to FALSE so they are no longer visible when the program runs.
                  I have changed the name of the Dialog.Message from "Notice" to "Click OK to create Reference". This will make more sense to the 'users'.

                  So in effect the app should now work as intended. THANK YOU!! for everything.

                  This is me with my class, saying Thank You!

                  Click image for larger version

Name:	2020 change.jpg
Views:	40
Size:	444.7 KB
ID:	305035

                  Comment

                  Working...
                  X