Nos permiten acceder a codigo javascript insertado en la pagina web . Una llama la funcion sin argumentos y la otra le pasa un argumento .
Unejemplo de lo que se puede conseguir con estas llamadas :
los metodos :
Code: Select all
METHOD ScriptCallMethod(cMethod) INLINE WEBSCRIPCALLMETHOD(::hWnd,cMethod)
METHOD ScriptCallMethodArg(cMethod,cArgumento) INLINE WEBSCRIPCALLMETHODArg(::hWnd,cMethod,cArgumento)
Code: Select all
HB_FUNC( WEBSCRIPCALLMETHOD )
{
WebView * Wview = ( WebView * ) hb_parnl( 1 );
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 2 ) ? hb_parc( 2 ) : "" ] autorelease ];
[[ Wview windowScriptObject] callWebScriptMethod: string withArguments:nil];
}
HB_FUNC( WEBSCRIPCALLMETHODARG )
{
WebView * Wview = ( WebView * ) hb_parnl( 1 );
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 2 ) ? hb_parc( 2 ) : "" ] autorelease ];
NSString * arg = [ [ [ NSString alloc ] initWithCString: ISCHAR( 3 ) ? hb_parc( 3 ) : "" ] autorelease ];
NSArray * args = [NSArray arrayWithObjects: arg , nil ];
[[ Wview windowScriptObject] callWebScriptMethod: string withArguments:args];
}
Code: Select all
#include "FiveMac.ch"
#xcommand @ <nRow>, <nCol> GET [ <oGet> VAR ] <uVar> ;
[ OF <oWnd> ] ;
[ SIZE <nWidth>, <nHeight> ] ;
[ VALID <uValid> ] ;
[ <update: UPDATE> ] ;
[ <lsearch: SEARCH > ] ;
=> ;
[ <oGet> := ] TGet():New( <nRow>, <nCol>, <nWidth>, <nHeight>,;
<oWnd>, bSETGET(<uVar>), [\{||(<uValid>)\}],;
<.update.>, ,<.lsearch.> )
#define NoMovil 0
#define AnclaRight 1
#define AnchoMovil 2
#define AnclaLeft 4
#define AnclaTop 8
#define AltoMovil 16
#define AnclaBottom 32
function Main()
local aTipos:= {"switchToTerrainMap","switchToSatelliteMap","switchToHybridMap" }
local oWnd, oTbr, oWeb
local path:= APPPATH()
local obtn3,obtn2,obtn1
local oseg
local oget1
local cDir:= ""
local nX
DEFINE WINDOW oWnd TITLE "WebView Test" TEXTURED ;
FROM 370, 650 TO 980, 1480
oWnd:Maximize()
@ 40, 20 WEBVIEW oWeb ;
SIZE oWnd:nWidth - 40, oWnd:nHeight - 120 OF oWnd ;
URL "file://"+path+"/GoogleMap.html"
@ 4 , 20 BUTTON obtn3 PROMPT "+" OF oWnd ACTION oWeb:ScriptCallMethod("zoomIn") SIZE 24,24
@ 4 , 44 BUTTON obtn2 PROMPT "-" OF oWnd ACTION oWeb:ScriptCallMethod("zoomOut") SIZE 24,24
BTNSETBEZEL(obtn2:hwnd,11)
BTNSETBEZEL(obtn3:hwnd,11)
oSeg:=Tsegment():new(4,140, 190,26,{|ele| oWeb:ScriptCallMethod(aTipos[ele] ) },oWnd)
oSeg:SetCount(3)
oSeg:SetLabel(1,"Plano")
oSeg:SetLabel(2,"Satelite")
oSeg:SetLabel(3,"Hibrido")
nX:=oWnd:nHeight-60
@ nX , 50 GET oget1 VAR cDir OF oWnd SIZE 660, 28 SEARCH
// oget1:bChanged := {||Cargadir(oWeb,oget1:getText()) }
TXTAUTOAJUST(oget1:hwnd,nor(8,4))
@ nX-5 , 730 BUTTON obtn1 PROMPT "Cargar " OF oWnd ACTION oWeb:ScriptCallMethodArg("showAddress",oget1:getText())
BTNAUTOAJUST(obtn1:hWnd,nor(8,4))
ACTIVATE WINDOW oWnd
return nil
//----------------------------------------------------------------------------//