Back

CreateCodeEdit

Hello World
Content:
- Methods

CreateCodeEdit is a control for premium users which is like a TextEdit but it has advanced methods.

cde = app.CreateCodeEdit( text, width, height, options ) → app object: CodeEdit

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.

Example - dark scheme

function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

    cde = app.CreateCodeEdit( "", 1, 1 );
    cde.SetText(app.ReadFile("/assets/templates/js/Simple.js"))
    cde.SetLanguage(".js");
    cde.SetColorScheme( "dark" );
    lay.AddChild( cde );


    app.AddLayout( lay );
}
    Copy     Copy All       Run      

Methods

The following methods are available on the CodeEdit object:

Copy()
Cut()
Focus()
GetAbsHeight() → number: integer
GetAbsWidth() → number: integer
GetCursorLine() → number: integer
GetCursorPos() → number: integer
GetHeight( options ) → number
GetLeft( options ) → number
GetLineStart( line ) → number: integer
GetParent() → app object
GetPosition( options ) → object: { left, top, right, bottom }
GetSelectedText() → string
GetSelectMode() → boolean
GetText() → string
GetTop( options ) → number
GetType() → string: “CodeEdit”
GetVisibility() → string: “Show” or “Hide” or “Gone”
GetWidth( options ) → number
Gone()
Hide()
IsEnabled() → boolean
IsOverlap( obj, depth ) → boolean
IsVisible() → boolean
Method( name, types, p1, p2, p3, p4 ) → all types
Paste()
Redo()
SetScale( x, y )
Show()
Undo()
boolean
app object
number
string
unknown
number: factor
number: fraction (0..1)
number: integer
number: milliseconds
number: -180..180
number: -100..100
number: 0..100
number: 0..0.99 or 1..256
string:
  hexadecimal: “#rrggbb”, “#aarrggbb”
  colourName: “red”, “green”, ...
string: comma “,” separated
string: html code
string: path to file or folder ( “/absolute/...” or “relative/...” )
string: comma “,” separated: “FillX/Y”
string: “px”
string: “screen”, “px”
string: “Up” or “Down”
string: “left-right” or “right-left” or “top-bottom” or “bottom-top” or “bl-tr” or “br-tl” or “tl-br” or “tr-bl”
string: “repeat”
string: “Add” or “Multiply” or “clear” or “darken” or “lighten” or “overlay” or “screen” or “xor” or “src_in” or “src_out” or “src_atop” or “src_over” or “dst_in” or “dst_out” or “dst_atop” or “dst_over”
string: “Dark” or “Light”
string: “.js”, “.java”, “.php”, “.c”, “.cpp”, “.cs”, “.rb”, “.m”, “.py”, “.txt”
string: “px” or “sp” or “dip” or “mm” or “pt”
string: “Yoyo” or “Touch”
string: “px” or “sp” or “dip” or “dp” or “mm” or “pt”
string: “px” or “dip” or “sp” or “mm” or “pt” or pl or ps
string: “Show” or “Hide” or “Gone”
string: “Linear.None” or “Quadratic.In/Out” or “Cubic.In/Out” or “Quartic.In/Out” or “Quintic.In/Out” or “Sinusoidal.In/Out” or “Exponential.In/Out” or “Circular.In/Out” or “Elastic.In/Out” or “Back.In/Out” or “Bounce.In/Out”
object: { x, y, w, w, sw, sh, rot }
list: boolean,char,byte,short,int,long,float,double,String,CharSequence,...
function()
function( action, keyname, keycode, extra )
cde.AdjustColor
Adjust the visual color effect of the control by setting the Hue (by angle in degrees in a color circle), the saturation, brightness and contrast of the control.
cde.ClearFocus
Removes the focus of the control so that the user no longer has immediate access to it.
cde.ClearHistory
Clears the undo/redo history.
cde.Copy
Copies the selected text to the device clipboard.
cde.Cut
Cut selected text and copies it to the device clipboard.
cde.Focus
Set the focus to the control so that the user can interact with it immediately.
cde.GetAbsHeight
Get the absolute height of the control in pixels.
cde.GetAbsWidth
Get the absolute width of the control in pixels.
cde.GetCursorLine
Returns the current line index where the cursor is located.
cde.GetCursorPos
Returns the index of the character where the cursor is currently located.
cde.GetHeight
Get the height of the control as screen height relative float or in pixels with the px option.
cde.GetLeft
Get the distance from the control to the left parent border as width relative float or in pixels with the px option.
cde.GetLineStart
Returns at which character in the text a certain line begins.
cde.GetParent
Returns the parent control object where the object was added to - commonly a layout.
cde.GetPosition
Returns data about the position and size of the control.
If the screen option is given the position on the screen will be returned. Otherwise relative to the parent control.
The px options turns the relative values into pixels.
cde.GetSelectedText
Returns the currently selected text.
cde.GetSelectMode
Checks if there is currently some text selected.
cde.GetText
Returns the current displayed text of the control.
cde.GetTop
Get the distance from the control to the upper parent border as height relative float or in pixels with the px option.
cde.GetType
Returns the control class name.
cde.GetVisibility
Returns the current visibility state of the control. The Values are:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
cde.GetWidth
Get the width of the control as screen width relative float or in pixels with the px option.
cde.Gone
Hides the control without consuming any more layout space as if it were never there.
cde.Hide
Hide the control but keep the layout space free.
cde.HighlightLine
Highlights a specific line in the text with a thin red underline.
cde.InsertText
Inserts a string at the current cursor position.
cde.IsEnabled
Returns whether the control is currently useable by the user.
cde.IsOverlap
Returns whether the control overlaps with another by a given distance.
cde.IsVisible
Returns whether the control is currently visible to the user, ignoring overlaying controls.
cde.Method
Allows access to other functions defined on the object in Java via reflection.

Note: This function is a premium feature. Please consider subscribing to Premium to use this feature and support DroidScript in its further development.
cde.Paste
Paste text from the clipboard at the current cursor position.
cde.Redo
Redo an undone action.
cde.Replace
Replaces the current selection with the passed text.
cde.ReplaceAll
Replace all occurances of a string in the text.
cde.ReplaceText
Replaces a given range in the text with some string.
cde.Search
Search for a string in the text in a given direction and selects it.
cde.SelectAll
Selects the whole text.
cde.SetBackAlpha
Set the transparency of the background by an alpha value between 0 (no transparency) and 0.99 (full transparent) or 1 (no transparency) and 256 (full transparent)
cde.SetBackColor
Changes the background color of the control.
cde.SetBackGradient
Define the background color of the control with a gradient. The default gradient direction is from top to bottom, but you can change it from left to right and the reversed versions of course.
cde.SetBackGradientRadial
Define a radial color gradient for the background of control.
cde.SetBackground
Changes the background to an image which can be repeated using the repeat option.
An image which is often used with that option is '/res/drawable/pattern_carbon' - try it out!
cde.SetColorFilter
Adjust the visual color effect with a color and a given BlendMode. More information about BlendMode can be found in the Android Developer page.
cde.SetColorScheme
Changes the color scheme of the CodeEdit.
cde.SetCursorPos
Change the curernt cursor position.
cde.SetEnabled
En/Disable the control physically and visually so that the user can/can not access the control. Events like OnTouch will still be fired.
cde.SetHtml
Change the current text of the control to html-formatted text.
cde.SetLanguage
Change the highlighted language syntax.
cde.SetMargins
Define a distance to other controls on each side of the control.
cde.SetNavigationMethod
Select between navigating using the Yoyo or standard touch.
cde.SetOnChange
Called when the containing data has been changed by the user.
cde.SetOnDoubleTap
Defines a callback function which is called when the user double-taps the Yoyo.
cde.SetOnKey
Define a callback function which is called when a key event appears.
cde.SetPadding
Define distances that elements within the control are to maintain from the control borders.
cde.SetPosition
Defines the position and size for the control if the parent is an absolute layout.
cde.SetScale
Scales the control along with its contents by the factors passed to the function.
cde.SetSelection
Selects part of the text in a given range.
cde.SetSelectMode
En/Disables the selection mode for the cursor.
cde.SetSize
Change the size of the control in either screen relative values or in pixels if the px option was given.
cde.SetText
Change the currently displayed text in the control.
cde.SetTextShadow
Define a shadow displayed around the control.
The sun is always shining so there has to be one. Always.
cde.SetTextSize
Change the size of the contained text.
cde.SetUseKeyboard
En/Disable usage of the device keyboard.
cde.SetVisibility
Change the visibility of the control to one of the available modes:
Show: visible
Hide: invisible but still consuming space
Gone: invisible and not consuming space
cde.Show
Set the visibility of the control to “Show”.
cde.Tween
Performs an animation on the control.
The target object is for the position, size and rotation that the control has at the end of the animation.

The type specifies the behavior and the speed of the animation. Separated by a dot, you must also specify whether you want to apply this behavior to the beginning (In), end (Out), or to both (InOut) times of the animation.

With the amount of repeats you can control how many times you want to play the animation.

If you have jojo activated, the animation will alternate between forward and backward playback, so that if the repetition value is odd, the control will be at the start position again at the end of the animation.

Finally the callback function will be called after the animation has finished. Well, it's about time!
cde.Undo
Undo an action.