Ok, now I'm trying to click on the webpage displayed via drawpic.
I put this in CSQC_InputEvent()
Code: Select all
switch(evtype){
case IE_KEYUP:
if (scanx == K_MOUSE1){
cefKey = gecko_keyevent(GECKO_SHD,scanx,evtype);
}
if (scanx == K_MOUSE2){
setcursormode(TRUE,"textures/cef/cursor.tga");
gecko_navigate(GECKO_SHD,"cmd:focus");
}
break;
case IE_MOUSEABS:
inputCursorOrg_x = scanx;
inputCursorOrg_y = chary;
//gecko_mousemove accepts only values between 0 and 1 so cursor coords must be normalized
cefCursorOrg = normalize(inputCursorOrg);
//avoid -coords
if(cefCursorOrg_x < 0){
cefCursorOrg_x = 0;
}
if(cefCursorOrg_y < 0){
cefCursorOrg_y = 0;
}
return TRUE;
}
gecko_mousemove () needs 0-1 values range so I had to normalize input coords and infact it works, but mouse coords don't correspond to webpage coords.
I used as webpage
this js demo that displays an eye following mouse coords. When I move the mouse, it only shows right and bottom directions. It's impossible to center the eye or go up or left.
This is Gecko_Draw()
Code: Select all
void Gecko_Draw(float w,float h)
{
if(gckSuccess){
gecko_resize(GECKO_SHD,w,h);
gecko_mousemove(GECKO_SHD, cefCursorOrg_x, cefCursorOrg_y);
cefProp = gecko_getproperty(GECKO_SHD,"title");
cefKey = gecko_keyevent(GECKO_SHD,0,0);
cefSize = gecko_get_texture_extent(GECKO_SHD);
drawpic([0,0,0],GECKO_SHD,[w,h,0],[0,0,0],1,0);
drawstring([15,15,0],vtos(cefCursorOrg),[10,10,0],[1,0,0],1,0);
drawstring([15,35,0],cefProp,[10,10,0],[1,0,0],1,0);
drawstring([15,55,0],ftos(cefKey),[10,10,0],[1,0,0],1,0);
drawstring([15,75,0],vtos(cefSize),[10,10,0],[1,0,0],1,0);
}
}
The drawstring() call prints cefKey but it shows a iterative counter like -0.0000000000000000000000000001246 which reaches 0 every 2 secs or whatever and it's not even related to click event.
I tried also
Code: Select all
case IE_KEYUP:
if (scanx == K_MOUSE1){
cefKey = gecko_keyevent(GECKO_SHD,K_MOUSE1,IE_KEYUP);
}
But with no success.
No I don't understand how to link mouse click event in fte to something web-related. For example click->get div id or click->click that button
Should i use something like
Code: Select all
traceline(project([inputCursorOrg_x ,inputCursorOrg_y,0]),project([inputCursorOrg_x ,inputCursorOrg_y,10000]),0,player);
string texname = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos));
but I already now the shader name (because it's drawn via drawpic())!
I noticed that gecko_resize() does the resize of the web page but it didn't set proportions correctly. Only vid_conautoscale did the trick but, honestly I don't like this solution because for some game I'd like to set it to 0, eventually..
Spike wrote:I did create an 'fte' scheme, so fte://data/* reads files from quake's filesystem
Well, I tried to put a index.html file in my gamedata folder but when I try to load it with
Code: Select all
gecko_navigate(GECKO_SHD,"fte://data/example.html");
it says "File not found within game filesystem". My data folder name is "data", but would it work for different games except Quake?
Spike wrote:
fte://ssqc/* fte://csqc/* fte://menu/* will invoke the Cef_GeneratePage qc function to generate page requests (make requests to your qc if you feel like doing so, maybe in conjunction with uri_unescape).
These ones I didn't even understand what they do..
****EDIT****
I noticed that showing webpages via playfilm in the console, will make click function enabled by default and it's possible to click on web links and scroll without doing anything!