How do I get OpenOffice Writer Combo boxes to display multi-line text? - forms

I am developing an OpenOffice Writer template that can be used to fill in reports for a child-care centre.
There are some standard outcomes, comprising long sentences, and I want the user to be able to select the appropriate sentence from a combo box. I have entered the sentences into a table in Openoffice Base database, which is then connected to a series of combo boxes in a Writer template. However, when the user choose an option that contains a very long sentence, only the text up to the length of the combo box is visible.
What I want to do is have the selected value of the combo-box wrap over several lines when selected so that all the (very long) text appears in the selected box when the user chooses a long sentence from the combo.
I have been looking through the properties of the combo box control, but have yet to identify one that will allow the selected value in the combo box to word-wrap (so that I could make the combo-box several lines in height such that the entire sentence would fit into the box).
Any pointers on how I could do this would be much appreciated.
thanks,
David.

Thanks Jim K, that was helpful. In the end, what I wound up doing was creating a textbox which I named "selectedOutcomeATextBox" immediately below my combo box which was named "OutcomeCombo".
I then attached the following macro code to the textModified event associated with the "selectedOutcomeATextBox":
Sub UpdateOutcomeA
Dim Doc As Object
Dim Form As Object
Dim Ctl As Object
Dim newCtl as Object
Doc = ThisComponent
Form = Doc.DrawPage.Forms.GetByIndex(0)
Ctl = Form.getByName("OutcomeCombo")
newCtl = Form.getByName("selectedOutcomeATextBox")
newCtl.Text = Ctl.Text
End Sub
I also set the "Printable" property of the "OutcomeCombo" to "No", so that when the document prints, the combo box itself does not appear on the printed page, but the "selectedOutcomeATextBox" textbox which has had its value set by the macro when I choose a value from the combo box does appear with the desired text. I also set the "TextType" property of the selectedOutcomeATextBox" text box to "Multi-Line", so that extra long text will wrap to the next line, thereby showing the very long strings that are stored there.
Thanks heaps Jim K.
cheers,
David Buddrige

Apparently combo boxes do not have the MultiLine attribute. The question was asked a few years ago here but was not solved.
One alternative that requires some macro programming is to use a single multi-line text field and then make a scroll bar button that changes the choice. Instead of a scroll bar, two buttons could be used to change the choice (Previous / Next), or even a list box control. Using a list box control in this way would have the advantage that they could see all the choices at once, like a combo box.
Another approach is to break up each sentence and display the parts across several lines of a list box. Then when one line is clicked, all the lines of a sentence are selected at once, using an event listener for the list box. This could be shown in addition to an ordinary editable multi-line text box, in case none of the answers in the list are wanted.
One more idea: Radio buttons can have multiple lines, so dynamically show radio buttons, one for each sentence. A dialog window could be displayed to hold the radio buttons. The result of the dialog would be used to fill the multi-line text field.
Or you could just live with the truncated sentences. Maybe it would help to make the control a little wider, or abbreviate the sentences.

Related

JavaFX: Need a custom control based on TextArea

I have the following requirement (sorry, but I'm quite new to JavaFX).
I need to have a custom TextArea that supports not only entering text but also entering a kind of macro.
This Macro has a unique ID and an associated text. The text should be displayed in the TextArea but with an e.g. light grey background. This is because it should behave as a unit.
You should not be able to click inside the macro and add a char there. The cursor should be placed behind the macro. And is you press just backspace the complete macro should be deleted.
If you call something like getRawContent() of the custom TextArea you should get a placeholder for the macro and not the associated text like:
getRawContent()
==> "This is text part one MACRO:132 This is text part two"
If the macro 132 has the following text associated "XXX123XXX", you will see inside the custom TextArea:
This is text part oneXXX123XXXThis is text part two"
But the text XXX123XXX has a light grey background to show that this text is associated with a macro and could be deleted, copied, and so on as a whole unit. Could be italic as well as in the above line. Should be only a bit different to the generic text.
Could someone assist me?
My Custom Control works now. I used an Eventfilter to prevent the internal Eventhandler to process the keypressed events in order to set the caret position behind a macro or delete the complete macro when DEL or BACKSPACE is pressed, this works.
And I use a Mouselistener to prevent that someone clicks and set caret position inside a macro.
So now I have only the problem left to mark the text somehow that the user can see what is normal text and what macro content.
Maybe I close here and open a new question.

How do I access the highlighted text in a Matlab GUI edit box

I would like to have a text box and a button in my GUI. When the button is pressed, a history window will come up, and if the user selects a previous entry the text that they have highlighted in the edit box will be overwritten.
It should work like copy-pasting, whatever is selected in the history window should be pasted over what is selected, or the new text should be added wherever the cursor is.
Is there any way in Matlab to do this? Is it possible to access what is highlighted in an edit box?
With vanilla Matlab this isn't possible. It appear that Mathworks is in the process of expanding what they support with GUIs (survey 1, survey 2), but as of yet they don't allow this.
One possible workaround is using findjobj.m, by Yair Altman. He discusses edit boxes in this post
You can trace findjobj.m for your text box to find 1 or 2 lines of code that are needed so you don't have to carry around all 3,400 lines of it.
Then all you really need to do is get the selected indices and work from there.
javaHandle = findjobj(editBoxHandle);
startSelect = get(javaHandle,'SelectionStart');
endSelect = get(javaHandle,'SelectionEnd');
Once you have the indexes of what text is selected, it becomes almost trivial to replace that text with the new text.
text = editBoxHandle.String;
editBoxHandle.String = [text(1:startSelect) newText text(endSelect:end)];
One thing to note, when the user clicks the button the text box will lose focus, and it will no longer be clear what text is selected. You can remedy this by giving focus back to the text box, and re-selecting what was selected in the button's callback.
uicontrol(editBoxHandle); %Give focus to the edit box, selecting the entire text
javaHandle.select(startSelect,endSelect); %select/highlight the correct stuff
This will highlight the text that will be replaced with the users selection

Bullet list text indent/align after tab

What I'm trying to do is create a bullet list in 'two columns'. So you have the bullet, a word, a tab and some aligned text like in the example below.
You have several alternatives:
Create a two-column table, with invisible lines. Fill the first column with your "bullet" word, and the second column with your "definition" (or whatever you are putting there.
Adjust the formatting for your special list item to include a tab where you want the text to appear and provide a "hanging indent" that lines up overflow text with that tab.
The second option is probably the best for you.

How to increase visual length of form text field in Word?

When a form text field is inserted in a Word document, the grey shaded length is about 5 characters long. How can this length be increased?
Allthough it is a rather crude measure (and I don't recommend it), you can set "Properties -> Default Text" to as many blanks as you want the size. But this comes for a price: as long as you move into the field by pressing TAB, all blanks are selected and get typed over. When you use the mouse, you click the cursor anywhere into the field and start typing ... so your entry might be pre and post fixed by a number of blanks that you have to trim away in e.g. an exit macro.
I recommend old form fields as the last resort (i.e. there must be a good reason to use them) and would prefer (in that order)
native Word2010/2007 fields (text or Rich text - perhaps not backwords compatible)
legacy ActiveX fields (compatible with W2003)
Legacy (old) form fields

How to handle variable width FieldObjects in Crystal Reports

I have a Crystal Report which is viewed via a CrystalReportViewer control on an .aspx page (using VS2008).
The report has two data-driven FieldObjects (which can contain a variable number of chars) which I would like to display on the same line beside each other.
Problem is when the text in the first FieldObject is too long it overlaps the text in the second FieldObject.
I have tried setting the 'CanGrow=True' and 'MaxNumberOfLines=1' on the first FieldObject to 'push' the second FieldObject further to the right, but this didn't work.
How do I get the second FieldObject to always display immediately after the first FieldObject regardless of the length of the text in the first?
Cheers in advance of any knowledge you can drop.
you can add a text object to the report. And while editing the text of the text object, drag the field you want to show from the object explorer into the text box. Then hit space, then drag the second field in to the same text box. Your two fields will always be one space a part. You could, of course, add more spaces or any other text you want.
Or you can create a function which returns field1 + " " + field2 and add the function to the report.