I'm trying to make a multiline button, but the text gets cut off.
Button button = new Button( containerButton, SWT.PUSH );
button.setText( "Hello\nWorld" );
Is it possible to adjust the height of a button?
The only thing I found was setSize( width, height ) but that's not working.
Thanks!
Toby
Try to give the button a layout data e.g. a GridData. Here you can set e.g. the heightHint. This should work.
Maybe a good article to read would be:
http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html
Related
This is an angular app (but anyone with css knowledge can help), where there is a text area with dynamic content.
So as the content item.text changes the text area should grow or shrink according to the content to fit the content perfectly without any overflow.
<textarea [value]="item.text" [placeholder]="item.text ? '' : 'Your Text Here...'" class="font-xl font-bold"></textarea>
// dont worry about the placeholder. you can ignore that.
Currently in my case scrollbar appears & it is not shrinking or growing with the dynamic content.
How can I achieve that?
Or if there is a way to convert a regular html <div> to a textarea, you can suggest that too. But prefers a solution for the above one.
I've tried css rules like, max-content fit-content etc... nothing is working out!
Install npm install ngx-autosize
in html add autosize
<textarea autosize [value]="item.text" [placeholder]="item.text ? '' : 'Your Text Here...'" class="font-xl font-bold"></textarea>
then in appmodule
put in imports: [AutosizeModule ],
Demo
This can't be accomplished with just css, it needs JavaScript that has quite a few corner cases and can be tricky. Such as, pasted input, input populated programatically, auto filled input, handling screen size changes correctly, and on and on, and doing so in a way that is reusable and performs well.
Given all that, I recommend using a lib for this.
I've used angular material's plenty of times with no issues, just add material to your project (can be done via angular CLI with ng add #angular/material) and either import the MatInputModule from #angular/material/input or TextFieldModule from #angular/cdk/text-field (TextFieldModule is quite a bit smaller) to the module where you want to use it, then do:
<textarea cdkTextareaAutoSize cdkAutosizeMinRows="5" [value]="item.text" [placeholder]="item.text ? '' : 'Your Text Here...'" class="font-xl font-bold"></textarea>
you can exclude the cdkAutosizeMinRows option and then it will default to 1 row, but you can use that option to set however many minimum rows you'd like to display. You can also use the cdkAutosizeMaxRows option to make it stop growing at a certain number of rows if you wish, otherwise it will grow indefinitely with the content.
blitz: https://stackblitz.com/edit/angular-4zlkw1?file=src%2Fapp%2Ftext-field-autosize-textarea-example.html
docs: https://material.angular.io/components/input/overview#auto-resizing-textarea-elements
https://material.angular.io/cdk/text-field/overview
You can't change the height of the textarea without Javascript. But you can use an editable div instead. In plain HTML something like this would serve the same purpose as an textarea and will resize automatically based on the content.
<div class="font-xl font-bold" contentEditable>Hello World</div>
If you use a <div> which you can edit then it can grow or shrink accordingly.
<div contenteditable="true">This is a div. It is editable. Try to change this text.</p>
The below will loop over the item and compare height to scrollHeight incrementing the height by lineHeight. Then resets the rows once the height is greater than the scroll height
(function () {
const el = document.querySelector('textarea');
dynamicallyResize(el);
el.addEventListener('change', function () { dynamicallyResize(el); });
})();
function dynamicallyResize(el) {
el == undefined && (el = this.target);
const lineHeight = 16;
let i = el.getAttribute('rows'),
height = Math.ceil(el.getBoundingClientRect().height);
el.style.overflow = 'visible'; //triger redraw
while(height < el.scrollHeight) {
height += lineHeight;
i++;
el.setAttribute('rows', i);
}
el.style.overflow = 'auto';
}
<textarea [value]="item.text" [placeholder]="item.text ? '' : 'Your Text Here...'" class="font-xl font-bold" rows="2">Starting text that exceeds the 2 row limit initially placed on this particular text area.</textarea>
Disable width and height fields from image properties I am using ckeditor 4
CKEDITOR.replace('<%=txtCkEditor.ClientID %>', {allowedContent:'img[!src,alt];'});
By using above method it shows only image properties with width and height hidden and rest of the controls also get visible false. Kindly suggest me a solution for disabling the width and height fields from image properties windows.
Thanks in advance.
I'm not sure I entirely understand your question. It seems you want to hide the fields that allow input of height and width. Your initial solution doesn't seem to affect the dialog box, but what content gets saved. These are very different kinds of solutions. My answer assumes you're seeking to alter the image properties dialog box fields.
Based on this earlier question, I recommend adding the following configuration:
CKEDITOR.on('dialogDefinition', function(ev) {
var editor = ev.editor;
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
if (dialogName == 'image') {
var infoTab = dialogDefinition.getContents( 'info' );
infoTab.remove( 'txtWidth' ); // Remove width element from Info tab
infoTab.remove( 'txtHeight' ); // Remove height element from Info tab
}
});
I am using dojo 1.7.2 and I have a datagrid. In one of the columns I have a long description that I want to show or hide when a "see more" link is clicked. I got all of that working with a formatter but when the description expands the datagrid's outer container does not get taller (in other words the rows below just get pushed down out of site. Is there anyway to change the height of the grid when I click on my show/hide (can the grid be redrawn? If so how?)
Update: I have created a js fiddle that shows what I want to do. You will see there is hidden text and when you click, it shows, but the rows at the bottom are pushed out of view:
http://jsfiddle.net/erayK/
Because I have to include some code, here is the formatter I used:
function formatLink(value){
// value 0: title, value 1: description, value 2: url
return ''+value[0]+'<br /><div style="display:none;" id="' + value[0] + '">'+value[1]+'</div>show or hide';
}
I found an acceptable solution, I can override the dojo styling that cuts off the stuff at the bottom and add a scrollbar using:
.dojoxGridContent {
overflow: auto;
}
I'm trying to change the background color for a row in a enhancedGrid. This is driving me crazy, thank you in advance for your time.
First, I select the row with onRowClick event.
function onRowClickHandler(evt) {
selectedRow = evt.rowIndex;
selectedCode = dijit.byId("myGrid").getItem(evt.rowIndex).code;
}
I need that the background color changes only when acertain button is clicked.
dijit.byId("myGrid").getRowNode(selectedRow).style+="backgroungColor:red;");
or
dijit.byId("myGrid").getRowNode(selectedRow).customStyle+="backgroungColor:red;");
This doesn't work.
I also tried with onStyleRow but it doesn't work.
I've tried with
dojo.style(dijit.byId("myGrid").getRowNode(selectedRow), "backgroundColor", "#454545" )
But the style does not remain fixed.
Thanks!
Take a look at this answer
Though I think if you override onStyleRow instead of using dojo.connect you should have this at the bottom of your custom function:
dojox.grid.EnhancedGrid.prototype.onStyleRow.apply(this, arguments);
I want to position a gtkButton on top of a gtkImage. I do this putting both inside a gtkFixed container. The problem now is that the button's tooltip is not shown anymore, when there is an image in the background. Without the image it works fine. How can I get the tooltip to be shown?
I am an R programmer so the below code is R-Gtk binding style, but should still convey the idea:
library(RGtk2)
w = gtkWindow()
image = gtkImage(file="tmp_1.png")
btn = gtkButton("Test")
gtkWidgetSetTooltipText(btn, "test")
fx = gtkFixed()
gtkFixedPut(fx, image, 10, 10)
gtkFixedPut(fx, btn, 10,10)
gtkContainerAdd(w, fx)
gtkWidgetShowAll(w)
Any ideas?
TIA.
You should use GtkOverlay widget. You add your GtkImage widget as main child of the overlay and the button with gtk_overlay_add_overlay.
That should work, and that's the preferred way of doing it.