Autosize Forge text markup box size based on contents - autodesk-forge

I have added some text markup using the following code:
const text = new Autodesk.Viewing.Extensions.Markups.Core.CreateText(
editor,
data.id
textPosition,
{ x: 1, y: 0.5 }, //Size of the label
data.name,
textStyleObject,
);
This looks like this when rendered:
Is there a way to automatically calculate the width of the label based on the content and reduce it accordingly so that it looks something like this:
Thanks in advance!

Related

How to separate out display and data mxgraph ports example

I am working with mxgraph and using the mxgraph ports example as a starting point for my application. https://jgraph.github.io/mxgraph/javascript/examples/ports.html
The example passes the content of each cell through the value property of an mxcell object. The display content is an html label which is then rendered inside the cell. Example code below shows the creation of an draggable icon on the sidebar the parameters are graph, sidebar, label, image.
addSidebarIcon(graph, sidebar,
'<h1 style="margin:0px;">Website</h1><br>'+
'<img src="images/icons48/earth.png" width="48" height="48">'+
'<br>'+
'Browse',
'images/icons48/earth.png');
The addSideBarIcon function then creates the vertex by passing it's label argument as the value property of the MxCell.
v1 = graph.insertVertex(parent, null, label, x, y, 120, 120);
I would like to be able to add a JSON object to store non display data along with the html label for display purposes in the value property of each cell. I would like to do this without modifying the underlying prototypes.
addSidebarIcon(graph,
sidebar, {
display: '<h1 style="margin:0px;">Process</h1><br>' +
'<img src="images/icons48/gear.png" width="48" height="48">' +
'<br><select><option>Value1</option><option>Value2</option></select><br>',
data: {
key1: val1
},
}
When I do this he code is interpreting the value as an html label. where as I would like it to interpret only value.display as the label. I'm not sure how to go about combining the html label and json data together and would love some suggestions.
You have the implementation of the addSidebarIcon in the same file...
When you find the:
v1 = graph.insertVertex(parent, null, label, x, y, 120, 120);
You have to use there not the "label", but extract the display value from your JSON.

Formatting a text area field in NetSuite to span over 3 columns

I was wondering if anyone knows how I could make text area fields in NetSuite span over the 3 columns.
These fields will have lots of text, so it would be nice to have the whole width of the page for each field.
Help would be much appreciated, thanks
A possible solution is to replace the field group Notes with a tab called Notes and add the text area to the tab instead of to the field group (container property set to ID of tab). A test looks like this (I started with the sample Suitelet from Answer Id: 43586):
Here's the relevant snippet:
var subtab = form.addTab({
id : 'custpage_subtab',
label : 'Subtab'
});
var field = form.addField({
id: 'textfield',
type: serverWidget.FieldType.TEXTAREA,
label: 'Text',
container: 'custpage_subtab'
});
Field groups will always use a common layout, according to my tests. So, if there is one field group with 3 columns, then all field groups will have 3 columns and a field cannot span multiple columns, so the idea behind my solution is to use another element, in this case a tab element to display the field content. The tab label is not displayed because there is only one tab. Hope this helps.
The following worked for me:
var fieldGroup = form.addFieldGroup({
id: 'group_notes',
label: 'Title'
});
var field = form.addField({
id: 'textfield',
type: ui.FieldType.TEXTAREA,
label: 'Notes',
container: 'group_notes'
});
field.updateLayoutType({
layoutType: serverWidget.FieldLayoutType.OUTSIDEBELOW
});
Relevant Netsuite documentation can be found here

Drawing text at different heights in CesiumJS

I'm trying to draw some text at a particular height (so it's drawn at the same height as some other primitive) in Cesium. Text-wise, I can't seem to be able to draw anything but labels clamps to the ground (in the example below, the first little circle is at ground level). As such:
var entity = viewer.entities.add({
position: Cesium.Cartesian3.fromDegrees(parseFloat(terrain[5]), parseFloat(terrain[4])),
ellipse : {
semiMinorAxis : 10000,
semiMajorAxis : 10000,
height : 1000,
fill : true,
outline: true,
material : Cesium.Color.fromCssColorString(someColour).withAlpha(0.5),
outlineWidth : 2
},
label: {
id: 'my label',
text: "Blabla",
scale: .5,
height: 1000
}
});
Is there any way to draw text at a specific height in Cesium?
The text height needs to be part of entity.position. Try adding it as a 3rd parameter to Cartesian3.fromDegrees on the 2nd line there.

show tinymce contents in a div with flexible though maximum height

When using an editor like tinymce, how could i limit the height of the text a user enters so it doesn't use more space on the webpage than i want it to?
There are 2 things that i want some advise on:
In the editor:
The user enters text in a tinymce editor, he could set a text to font-size say 80px which would use up more space than a normal letter. So it's not the amount of text that i care about it's the height of the total.
In the webpage:
I don't want to give them more than say 200px worth of text on the page. But if they enter just 1 line of text with a small font-size i don't want to show a 200px space. So the height has to be flexible but with a maximum.
I know this isn't exact science but the goal here is to prevent the user from messing up the page.
To solve a similar issue i wrote the following function (placed inside an own tinymce plugin). You will need to add a variable for the maximum case and maybe tweak it a bit, but i hope this code will put you into the right direction
// this function will adjust the editors iframe height to fit in the editors content perfectly
resizeIframe: function(editor) {
var frameid = frameid ? frameid :editor.id+'_ifr';
var currentfr=document.getElementById(frameid);
if (currentfr && !window.opera){
currentfr.style.display="block";
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight + 26;
}
else if (currentfr.Document && currentfr.Document.body.scrollHeight) { //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
}
styles = currentfr.getAttribute('style').split(';');
for (var i=0; i<styles.length; i++) {
if ( styles[i].search('height:') ==1 ){
styles.splice(i,1);
break;
}
};
currentfr.setAttribute('style', styles.join(';'));
}
},

Want to get cursor position within textInput

I am using textInput within grid using rendrer. I am populating a suggestion box just below the text input field on the basis of typed character and index of text input.Problem is that if i shrink grid column then suggestion box is not populating at the right place so I want global position of cursor in the text input field .
Something like that:
var inputTxt : TextInput = new TextInput;
var x : Number = inputTxt.cursorManager.currentCursorXOffset;
var y : Number = inputTxt.cursorManager.currentCursorYOffset;
Try using 'global coordinate'.
This might resolve your problem.