This is my first question on here. So.. I apologize if I ask this poorly.
I've written a syntax highlighted text editor that extends the spark TextArea.
The highlighting works by applying ApplyFormatOperations to the various different sections of text. However, as soon as I apply any format operations, I lose all the built in undo/redo functionality. I turn off the colorizing and undo redo comes back.
Here's a simplified version of what I'm doing that wipes out undo/redo.
Imagine this gets triggered every time you type a character.
//select everything
var operationState:SelectionState = new SelectionState(textFlow, 0, text.length);
//make an example format.
var exampleFormat:TextLayoutFormat = new TextLayoutFormat();
//everytime we run change the color of all the the text.
m_undoTest = !m_undoTest;
if (m_undoTest) {
exampleFormat.color = "#0839ff"; //make all text bluish.
} else {
exampleFormat.color = "#ff0839"; //make all text redish.
}
//make an operation to apply my formatting.
var formatOperation:ApplyFormatOperation = new ApplyFormatOperation(operationState, exampleFormat, null);
//apply the operation to the text area.
formatOperation.doOperation();
Now my text toggles from red to blue as I type and I can no longer undo. Interestingly if I do the same steps but don't change any properties in the new format. IE don't toggle the color everytime we run. Undo Redo does still work.
Any help would be greatly appreciated, thanks :)
Well... I got further on this, by piping all my operations through the "editManager" class I no longer lose the undo redo history. But... the colorization now counts as an undoable action... which as you might imagine is not ideal. So, now intermixed with your actual undos you have ones that remove all the syntax highlighting. Still trying to figure out a way around that.
The jist of the current implementation is this:
var editManager:IEditManager = textFlow.interactionManager as IEditManager;
//make an operation to apply my formatting.
var formatOperation:ApplyFormatOperation = new ApplyFormatOperation(operationState, exampleFormat, null);
//apply the operation to the text area.
editManager.doOperation(formatOperation);
Related
New to coding, trying to see what/if Tags would make this code work
So I'm a beginner with basic understanding and more of a Graphics/ Designer than code based. I found a codepen by WEDOO that has exactly what I need and want to try to just swap my "animationData" to see if I can get it to work and then modify it as needed for my test (will be assign the button code to various objects for the SVG). I Can't seem to find the right "Tags" or determine if its referencing an external script...I'd image it just needs the right information to function...is that correct?
Thanks in advance!
var animation = bodymovin.loadAnimation({
container: targetAnim,
path: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/914929/data-testo4.json...
My output from BodyMovin in a JSON file:
var animationData =
{"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
Does it make sense to think that I need replace the var animation with info that should be the targetAnim with the code in the JSON file? So far put the var animationData breaks things and does nothing (visually).
The bodymovin.loadAnimation can be passed either a URL to a Bodymovin JSON via the path option OR you can pass the animation JSON inline by setting the animationData option instead.
In you case it would end up looking something like:
var animation = bodymovin.loadAnimation({
container: targetAnim,
animationData = {"v":"5.4.2","fr":29.9700012207031,"ip":0,"op":149.000006068894...
...
})
I need to do something very simple and straight forward in google sheets. I was able to perform this on Excel, but just haven't resolved it in sheets
I have a sheet with stock figures for printer cartridges. Next to the total of cartridges available i want to add a 'plus' and 'minus' button (i have the buttons in place ready) what i want them to do is add or minus 1 to the figure in the total box. I just cant work out the script at all.
I did it in Excel using the following
Sub Button1_Click()
Range("A1") = Range("A1") + 1
End Sub
But that doesn't work at all in sheets.
Please dont mock me for this, I am a complete new comer to scripting so very much learning the tricks of the trade.
Thanks in advance to anyone who helps
Select the Tools menu and click Script Editor. Copy and paste the following code.
function plus() {
ss=SpreadsheetApp.getActiveSpreadsheet()
s=ss.getActiveSheet()
var currVal=s.getRange("A1").getValue()
var plusVal= currVal +1
s.getRange("A1") .setValue(plusVal)
}
function minus() {
ss=SpreadsheetApp.getActiveSpreadsheet()
s=ss.getActiveSheet()
var currVal=s.getRange("A1").getValue()
var minusVal= currVal -1
s.getRange("A1") .setValue(minusVal)
}
From you sheet right click on the shape (button) and click the arrow. From the menu select Assign Script. Enter plus (for the plus button). This is the function name for the plus function. Repeat for the minus button assigning the minus function.
The first time you run the script you will see two popups. Continue and Accept in the popup windows.
I have almost 0 scripting experience with UDK, but I think what I'm trying to do is fairly simple. I want to define a variable in script that I can then access in Kismet.
This is what I have so far:
MyGameInfo.uc looks like this
class MyGameInfo extends UDKGame;
defaultproperties{
PlayerControllerClass=class'MyGameInfo.MyPlayerController'
}
event InitGame( string Options, out string Error )
{
// Call the parent(i.e. GameInfo) InitGame event version and pass the parameters
super.InitGame( Options, Error );
// Unreal Engine 3
`log( "Hello, world!" );
}
MyPlayerController.uc looks like:
class MyPlayerController extends UDKPlayerController;
var() localized string LangText;
defaultproperties{
LangText="asdfasdf";
}
Then, in Kismet I'm using Get Property, with player 0 as the target, attempting to get property LangText. I have the string output going to Draw Text (and yes, I made sure to set a font).
It looks like this:
I feel like I'm really close, but no text shows up in the Draw Text. Any ideas?
Also, why am I trying to do this? For localization purposes. As far as I can tell, there's no easy way in Kismet to use localized strings for Draw Text. My thinking is just to create a localized string for each piece of dialog and then call those strings from Kismet as needed.
You need to make sure you added a Font asset from the content browser in the DrawText properties, and check it is actually placed on the screen (try Offset 0,0 for centered text)
Also, I think that DrawText doesn't work in UTGAME - in case that's your gametype. It works in UDKGame.
And if you have ToggleCinematic mode enabled, then check Disable HUD isn't on.
Test the DrawText with a regular string first...
Try using Player Spawned event instead of Level Loaded, as it may fire too fast for the player to have been added in the game yet.
I have a weird issue that I am being asked to fix but alas I have thus far drawn a blank. As the title suggests I am trying to get the tab order for two text boxes to follow one after the other.
The idea is (and this is inherited code rather than that of my own design) that a routine is call that builds atable cell inserting two text boxes and one link. This is then returned and foreach line in the table a new copy of this cell is generated.
I have tried setting the TabIndex for the text boxes and find that when I tab I only get as far as the first box (txtPound) and never the second (txtPence).
I can't decide if the issue is due to trying to do this in a TableCell or whether its something else completely.
Hopefully that's clear but should you require any further info then I will try to supply it.
I have included a striped down version of the code below, essentially this gets added to a table row in a the aspx pace.
Any help would be greatly appreciated.
private TableCell EstimateInputs(Brief item)
{
TableCell td = new TableCell();
TextBox txtPounds = new TextBox();
string[] agencyCosts;
txtPounds.TabIndex = 1;
td.Controls.Add(txtPounds);
//td.Controls.Add(new LiteralControl("<span>.</span>"));
TextBox txtPence = new TextBox();
txtPence.MaxLength = 2;
txtPence.TabIndex = 2;
td.Controls.Add(txtPence);
td.Controls.Add(new LiteralControl("</p></fieldset>"));
}
So it ended up being a complete red herring. turns out that there was a little JavaScript function that is applied to text boxes that deal with monetary values. it stops anything other than a numerical key press which means it includes the tab key.
So the mystery is solved - thanks for the help.
I need to have a Text Area With Line Numbers,
& once the Text File is Imported to the Text Area..
the user must be able to select the line numbers & see the filtered output.
I have implemented the same with Numeric steppers.
I am in search of an enhanced component.
are there better Advanced Components for Textarea ?
Any Advanced Textarea component with built-in Search/Replace/Filter Capabilities ?
Cheers,
Ajay
What do you consider to be a line? Do you need to take the line wrapping of the text area into consideration when you are selecting the lines, or are you only interested in the actual line characters in the underlying string?
If the latter applies, the you can probably accomplish what you want like this:
protected var selectedLineIndexes:Array = []; // of ints
// Find the lines which were selected.
textArea.text.split("\n").filter (
function (line:String, i:Index, a:Array):Boolean {
return selectedLineIndexes.indexOf(i) != -1;
}
)
If you are actually interested in the lines in the view, taking the width of the text area into account, then it will be more complicated. In this case, the TextLineMetrics class will probably come in handy. You can obtain a reference from the IUITextField which is a protected property of the TextArea. I.e. you need to subclass TextArea to get access to this information.
http://livedocs.adobe.com/flex/3/langref/flash/text/TextLineMetrics.html
http://livedocs.adobe.com/flex/3/langref/mx/core/IUITextField.html