I have used the Flash UIScrollbar component to scroll my texts which i have imported externally. Is it possible manipulate the scrollbar to put it in specific line of text? In default the scrollbar placed at the beginning of the text, but I want to it placed at the end or middle or specific line of text.
scrollPosition : Number Gets or sets the current scroll position and
updates the position of the thumb.
example:
myScrollBar.scrollPosition = 45;
Source:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/ScrollBar.html
Related
I've used #angular/cdk/drag-drop library to implement a drag and drop functionality. It works well, however when dragging an element, the layout of dragged item (div containing mat-angular dropdowns, delete icon and drag handle) breaks.
As soon as I place the item it is back in place looking as it should (img 1), but it looks like during dragging the item loses its parent div, therefore it is not inline, as well as not retaining the same dimensions (img 2)
This is how it looks before dragging
This is how it looks during dragging
I've attempted to solve this with adding a class with required width and height + set its display property to inline flex, however it does not help.
I am trying to write a simple GUI for editing key-value pairs in TCL+Tk. It is based on a vertical ttk::panedwindow widget containing an arbitrary number of horizontal ttk::panedwindow widgets, each with a ttk::entry on the left side and a text widget on the right side. Below the main ttk::panedwindow is a frame containing buttons to do things like saving and loading files and adding new rows. This works fine, with all widgets scaling as I expect them to, but when more rows are added they get squeezed together or stretch the window.
Trying to make the window vertically scrollable didn't work properly. Tk is unfortunately very picky about what it will let me attatch scrollbars to, so I couldn't just put one on the main ttk::panedwindow. I tried various hacks listed on wiki.tcl.tk, but most of them use a canvas widget and scroll in both directions. If I remove the horizontal scrollbar, it won't be there anymore but the widgets will still extend beyond the edge of the window or stop before the edge of the window.
I also tried BWidget, but I didn't understand the relationship between the ScrolledWindow and ScrollableFrame widgets that I was told to use together. When I followed the examples they had the same problem as the canvas version. I suspect that they actually use a canvas internally rather than implementing a true scrollable frame.
How can I make the main interface scale to the dimensions of the window while also allowing vertical scrolling? I'm using Linux, if that helps.
I made a GIF to show what I want:
dissapearing scrollbar is optional, it just happened like that. The changing scribbles represent the lines of text adjusting to the available space.
So… you want the content to be “natural” in the vertical direction, yet stretched in the horizontal direction? Tricksy.
Your basic approach is going to be to put a frame (or ttk::frame) inside a canvas, put your “interesting” content inside the frame and add a scrollbar to the canvas. However, that's not the tricky bit. The tricky part is that you need to notice changes to the dimensions of the canvas and to the dimensions of the frame; a change to the frame should cause the adjustment of the canvas's bounding box, and a change to the canvas should cause adjustment to the requested width of the frame.
To notice a change to the size of any widget, you bind to the <Configure> event sent to that widget and use the %w and %h to get the width and height that the widget is being set to. (Indeed, geometry managers like grid and pack work exactly like that internally, except they use C-level bindings and not script-level ones.)
bind $canvas <Configure> {adjustCanvasDimensions %W %w %h}
bind $frame <Configure {adjustFrameDimensions %W %w %h}
proc adjustCanvasDimensions {theCanvas width height} {
set theFrame $theCanvas.frame
set oldwidth [$theFrame cget -width]
if {$width != $oldwidth} {
$theFrame configure -width $width
}
# Consider adjusting the frame height if canvas height greater
}
proc adjustFrameDimensions {theFrame width height} {
set theCanvas [winfo parent $theFrame]
$theCanvas configure -bbox [list 0 0 $width $height]
}
Or something like that. This is untested code (and assumes you put the frame in the canvas, etc.) but ought to show you the way forward.
I have been given a very specific requirement on how to display a list of messages. Each message can be up to 3200 characters long. For this particular display of the messages, only the first two lines of each are to be displayed, showing whatever fits of the message with the original format intact (tabs, spaces, newlines). The messages are to be contained in a JInternalFrame. When the user drags a side of the frame to increase or decrease its width, the visible text of a message is supposed to increase or decrease along with the frame, no horizontal scroll bar is desired.
I was able to get the desired behaviour with the text increasing/decreasing with the width of the frame using the following:
JTextArea ta = new JTextArea();
ta.setLineWrap(true);
ta.setWrapStyleWord(true);
ta.setRows(2);
ta.setEditable(false);
ta.setOpaque(false);
ta.setText(longString());
ta.setAlignmentY(TOP_ALIGNMENT);
JScrollPane scrollPane = new JScrollPane(ta);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
A list of scrollPanes are added to a JScrollPane with a vertical scroll bar but no horizontal scroll bar in the JInternalFrame.
The problem I am having is that the text is resting on the bottom of the JTextArea, so the user sees the last two lines of the message, not the first two lines. It appears to be possible to set the horizontal alignment, but not the vertical alignment. Is there some way to get the automatically expanding/contracting text with text alignment at the top?
This is something that's bugged me in the past as well. It has to do with how JTextComponents interact with JScrollPanes - specifically, there is a (invisible, when non-editable) Caret that ends up at the end of your JTextComponent. When the viewport tries to figure out what it should be viewing, it looks at the caret.
So, tell the JTextArea not to move the caret during your initialization block:
DefaultCaret c = new DefaultCaret();
c.setUpdatePolicy( DefaultCaret.NEVER_UPDATE );
ta.setCaret( c );
After loading text into the text area you can use:
textArea.setCaretPosition(0);
I have a text area that I'm adding html (within a CDATA tag of course) to from an xml file. The text is adding fine and the field is scrolling fine when I add extra text, but as soon as I an <img> to it the image shows up but the fields inner height (the overflow part) does not adjust for the <img> so i can't scroll down to see the rest of the image (I even added a width and height, but to no aval ).
Is there a way to adjust the inner height of the text field via as3 so the field can be scrolled to the bottom of the image?
i think you'd be better off with webview or something. Text area has htmlmode, but not all features are supported. Plan B: you can implement your own parser, what makes the text as you want it.
I have a very long jpanel on a jscrollpane.
I want to be able to jump to a location in the panel.
is there a way to jump to a specific point in the pane?
Setting the horizontal scrollbar value is not enough
Is there a way to mark a position and jump to it (rather than giving X,Y)?
Thanks.
See scrollRectToVisible for scrolling.
Not sure what you mean with "mark a position" but if you want to scroll to for example a text field that is a (direct) child of the panel than you would do:
panel.scrollRectToVisible(textField.getBounds());