[Tip] Show Tooltips

127 views
Skip to first unread message
Message has been deleted

Vlad Cheater

unread,
Dec 18, 2016, 8:29:31 AM12/18/16
to DroidScript
Wow, this is amazing!
Thank you Dave!

Symbroson Development

unread,
Dec 18, 2016, 8:48:31 AM12/18/16
to DroidScript
Isn't that a bit useless because there's already a SetHint function?
but ok if you like it ^^

Steve Garman

unread,
Dec 19, 2016, 1:15:19 AM12/19/16
to DroidScript
Alex,
The tooltip does not perform the same function as SetHint at all.

edt.SetHint only displays in an empty TextEdit and cannot be seen at all without removing any content.

The tooltip is not associated with any control and can be displayed anywhere on the screen when required.

In the app from which the screenshot is taken, the TextEdit is prepopulated with a sampe URL and the tooltip is displayed when the "?" button is pressed.

Steve Garman

unread,
Dec 19, 2016, 2:03:34 AM12/19/16
to DroidScript
Here is a longer "use it like this" example.

function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
img = app.CreateImage( "/Sys/Img/Droid1.png", 0.5 );
img.SetOnTouchUp( showTip );
lay.AddChild( img );
app.AddLayout( lay );
}
function showTip()
{
var pos = img.GetPosition();
var btm = pos.top + this.GetHeight()*2/3;
var msg = "This is a picture of a droid. <br>It comes from System Resources";
app.ShowTip(msg, pos.left, btm);
}

JAUREGUI

unread,
Dec 19, 2016, 3:14:16 PM12/19/16
to DroidScript
That's just great, thanks it will be very useful...

Erina Ebru

unread,
Dec 19, 2016, 3:43:33 PM12/19/16
to DroidScript
This is absolutely great. Totally cool 4 tutorials or so🤗☺🤗

Symbroson Development

unread,
Dec 19, 2016, 3:45:47 PM12/19/16
to DroidScript
Ok thats a good usage ur right ^^

MyScripts

unread,
Nov 2, 2019, 10:27:10 AM11/2/19
to DroidScript
tooltip when clicked gives an error [ script error: func.apply is not a function, source: file:///android_asset/app.js line: 1606]

Steve Garman

unread,
Nov 2, 2019, 11:08:42 AM11/2/19
to DroidScript
The code in this thread was very old and used out-of-date callback syntax.

It has been replaced with
app.ShowTip()
There is example code in the latest docs.

I can't remember offhand whether ShowTip is a premium feature but it's not flagged in the docs as such.

Steve Garman

unread,
Nov 2, 2019, 11:21:57 AM11/2/19
to DroidScript
It looks like the same func.apply problem has made it into the api version as well.

Looks like nobody tested touching the tooltip.

MyScripts

unread,
Nov 2, 2019, 11:55:25 AM11/2/19
to DroidScript
How could I fix this in app.js?

line 1606

function _Call( id, func, params)
{ if( func ) func.apply( _map[id], params ); }

Symbroson

unread,
Nov 2, 2019, 12:10:20 PM11/2/19
to DroidScript
 as quick fix, add this line to your code after the ShowTip call:

_cbMap['3533501187'] = _dlgTip.Dismiss;

However don't keep that in your code because it will break if any slight change on the internal OnToch method is made.

MyScripts

unread,
Nov 2, 2019, 12:24:37 PM11/2/19
to DroidScript
OK thank you :) could this be added to droidscript app.js? In file: ///android_asset/app.js, create a line of code to fix this or should i expect an update?

Symbroson

unread,
Nov 2, 2019, 12:33:03 PM11/2/19
to DroidScript
It 's likely to be fixed in one of the next updates.
btw the issue is not located in app.js

MyScripts

unread,
Nov 2, 2019, 12:43:38 PM11/2/19
to DroidScript
ok anyway thanks for the help.

Dave

unread,
Nov 6, 2019, 12:06:04 PM11/6/19
to androi...@googlegroups.com
This is now fixed in alpha 179a2 (soon to be released)

In the mean time a better fix would be to put this somewhere in your code (it overrides the internal DS version):-


//Show a tooltip message.
var _dlgTip = null;
_ShowTip
= function( msg, left, top, timeOut, options )
{
   
//Get options.
   
if( options ) options = options.toLowerCase();
   
else options = "";
   
   
//Remove old tip if still showing.
   
if( _dlgTip ) { _dlgTip.Dismiss(); clearTimeout(_dlgTip._tm) }
   
   
//Create dialog window.
    _dlgTip
= app.CreateDialog( null, "AutoCancel,NoDim,"+options );
    _dlgTip
.SetBackColor( "#00000000" );
    _dlgTip
.SetPosition( left, top );
   
   
//Create tip layout.
   
var layTipDlg = app.CreateLayout( "linear", "vertical,fillxy" );
   
   
//Create tip text.
   
var txt = app.CreateText( msg, -1,-1, "MultiLine,left,Html" );
    txt
.SetTextSize( 22, "ps" );
   
if( options.indexOf("up")>-1 ) txt.SetBackground( "/Res/drawable/tooltip_up" );
   
else  txt.SetBackground( "/Res/drawable/tooltip_down" );
    txt
.SetOnTouch( function() { _dlgTip.Dismiss() } );
    layTipDlg
.AddChild( txt );
   
   
//Add dialog layout and show dialog.
    _dlgTip
.AddLayout( layTipDlg );
    _dlgTip
.Show();
   
if( timeOut ) {
        _dlgTip
._tm = setTimeout( function(){
           
if(_dlgTip)_dlgTip.Dismiss(); _dlgTip=null
       
}, timeOut );
   
}
}


MyScripts

unread,
Nov 6, 2019, 12:21:36 PM11/6/19
to DroidScript
I will wait for the new version but in the meantime I will use your code, thanks!
Reply all
Reply to author
Forward
0 new messages