TPanel Left click mouse is possbible?

Post Reply
MGA
Posts: 1269
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

TPanel Left click mouse is possbible?

Post by MGA »

TPanel Left click mouse is possbible?

Code: Select all | Expand

DEFINE WINDOW oWnd TITLE "Dashboard " 
   *** Paneles
      
   oPanelWeb := TPanel():New( 0, 281, oWnd:nHeight, oWnd:nWidth, oWnd ) 
  
   oPanelWeb:blclicked := {|| msginfo("test")}  <---------
   
   oWebView := TWebView2():New(oPanelWeb)      
   oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )   
   oWebView:SetHtml( MiHtml(1) ) 
   oWebView:Run()   

ACTIVATE WINDOW oWnd MAXIMIZED ON RESIZE
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
User avatar
karinha
Posts: 7988
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 6 times
Contact:

Re: TPanel Left click mouse is possbible?

Post by karinha »

Bira, mira se ayuda:

Code: Select all | Expand

// C:\FWH\SAMPLES\BIRAPAN.PRG

#include "FiveWin.ch"

STATIC oWnd, OPANELWEB, OWEBVIEW

FUNCTION Main()

   DEFINE WINDOW oWnd TITLE "Dashboard " // ** Paneles

   oPanelWeb := TPanel():New( 0, 281, oWnd:nHeight, oWnd:nWidth, oWnd )

   WITH OBJECT oPanelWeb

      oWnd:bRClicked := { || ( FUNDOBIRA() ) } // Mouse Direito

      oWnd:bLClicked := { || ( FUNDOBIRA() ) } // Mouse Esquerdo

   END

   oWebView := TWebView2():New( oPanelWeb )
   oWebView:SetUserAgent( "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 Mobile Safari/537.36" )
   oWebView:SetHtml( MiHtml( 1 ) ) // ?? Mostre isso Bira, fiquei curioso.
   oWebView:Run()

   ACTIVATE WINDOW oWnd MAXIMIZED // ON RESIZE ??

RETURN NIL

FUNCTION FUNDOBIRA()

   ? [AQUI ESTOU BIRA]

RETURN NIL

// FIN / END - kapiabafwh@gmail.com
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
MGA
Posts: 1269
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá
Contact:

Re: TPanel Left click mouse is possbible?

Post by MGA »

Joao,

não funciona.
ubiratanmga@gmail.com

FWH24.04
BCC7.3
HARBOUR3.2
xMate
Pelles´C
TDolphin
User avatar
Antonio Linares
Site Admin
Posts: 42716
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 93 times
Been thanked: 103 times
Contact:

Re: TPanel Left click mouse is possbible?

Post by Antonio Linares »

The WebView control covers all the window parent area so you can not use bRClicked

Use a javascript event called function that jumps to FWH using javascript SendToFWH()

If you provide function MiHtml() source code then we can help you to implement it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: TPanel Left click mouse is possbible?

Post by Silvio.Falconi »

Antonio Linares wrote: Fri Mar 21, 2025 10:44 pm The WebView control covers all the window parent area so you can not use bRClicked

Use a javascript event called function that jumps to FWH using javascript SendToFWH()

If you provide function MiHtml() source code then we can help you to implement it
Antonio ,
a long time ago I used a simple html without the Twebview class, I connected to an html page that I had on a server, the page was formed as a dashboard with all the icons, if I pressed a button or the writings I could open the procedures that were in the program without using javascript, I have to find the example again and I'll show it to you

run also on local

look the video
Image

I use a simply activex

oActiveX := TActiveX():New( oWndBrowser, "Shell.Explorer" )
oActiveX:bOnEvent := { | event, aParams, pParams | EventInfo( event, aParams, pParams, oActiveX ) }

on Eventinfo I insert

Code: Select all | Expand

 
  if ( "index.html" $ cParam .and. "#" $ cParam )

            cCommand := SubStr( cParam, At( "#", cParam ) + 1 )

            if !Empty( cCommand )
                            &cCommand
                        end if
                        
sample on html

Code: Select all | Expand

<ul class="post-content-button">
                            			<li class="post-contenido-button"><img src="img/gc_document_text_user.png" class="imagen"></li>
                                		<li class="post-contenido-button"><font class="tituloboton"><a href="index.html#AppFacCli()">A&ntilde;adir nueva factura</a></font></li>
                            		</ul>
when I click on "A&ntilde;adir nueva factura" I open the procedure index.html#AppFacCli()


I not Know TwebView or TwebView2 because I never use these object classes, exist a codeblock to insert as bonEvent ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: TPanel Left click mouse is possbible?

Post by Silvio.Falconi »

an sample test with webview

mihtml.html

Code: Select all | Expand


<!DOCTYPE html>
<html lang="it">
<head>
    <meta charset="UTF-8">
    <title>Test TWebView</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f0f0f0;
        }
        .post-content-button {
            list-style: none;
            padding: 0;
            display: flex;
            align-items: center;
            background-color: #ffffff;
            border: 1px solid #ccc;
            border-radius: 5px;
            box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
        }
        .post-contenido-button {
            margin: 10px;
        }
        .imagen {
            width: 24px;
            height: 24px;
            vertical-align: middle;
        }
        .tituloboton {
            font-size: 16px;
            color: #333;
        }
        a {
            text-decoration: none;
            color: #0078d7;
        }
        a:hover {
            text-decoration: underline;
            color: #005bb5;
        }
    </style>
</head>
<body>
    <ul class="post-content-button">
        <li class="post-contenido-button">
            <img src="img/test.png" class="imagen" alt="Image">
        </li>
        <li class="post-contenido-button">
            <font class="tituloboton">
                <a href="#" onclick="callHarbourFunction('AppFacCli'); return false;">Añadir nueva factura</a>
            </font>
        </li>
    </ul>

    <script>
        function callHarbourFunction(funcName) {
            if (window.chrome && window.chrome.webview) {
                window.chrome.webview.postMessage(funcName); 
                alert("Messaggio inviato a Harbour: " + funcName); 
            } else {
                alert("WebView2 non è disponibile!");
            }
        }
    </script>
</body>
</html>



test.prg

Code: Select all | Expand


#include "FiveWin.ch"

FUNCTION Main()
   LOCAL oWebView := TWebView():New( 0, 0, 800, 600 ) // Create the WebView control
   LOCAL cHtml := MemoRead("mihtml.html")   // Upload your HTML

   // Set up binding to receive messages from the web
   oWebView:bOnBind := {|cMessage| ExecuteFunction(cMessage) }

   // Load the HTML
   oWebView:SetHtml(cHtml)
   oWebView:Run()

RETURN NIL

FUNCTION ExecuteFunction(cFuncName)
   IF cFuncName == "AppFacCli"
      AppFacCli() // Call your Harbour function
   ENDIF
RETURN NIL

FUNCTION AppFacCli()
   MsgInfo("here your harbour/fwh  codes!")
RETURN NIL
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: TPanel Left click mouse is possbible?

Post by Silvio.Falconi »

Antonio,
Please why it make error ?

Code: Select all | Expand

#include "FiveWin.ch"

FUNCTION Main()
   LOCAL oWebView := TWebView():New()

   oWebView:SetHtml( Html() )
   oWebView:SetTitle( "Test AppFacCli" )
   oWebView:SetSize( 800, 600 )
   oWebView:Bind( "SendToFWH" )
   oWebView:bOnBind := {|cJson, cCalls| ExecuteFunction(cJson, cCalls, oWebView) }
   oWebView:Run()
   oWebView:Destroy()

RETURN NIL

FUNCTION ExecuteFunction(cJson, cCalls, oWebView)
   LOCAL hData

   // Decodifica il JSON ricevuto dal JavaScript
   hb_jsonDecode(cJson, @hData)

   // Controlla il contenuto del JSON
   IF hb_HHasKey(hData, "function") .AND. hData["function"] == "AppFacCli"
      AppFacCli()
      oWebView:Return(cCalls, 0, "{ 'result': 'AppFacCli eseguita con successo!' }")
   ELSE
      oWebView:Return(cCalls, 0, "{ 'result': 'Funzione non riconosciuta' }")
   ENDIF

RETURN NIL

FUNCTION AppFacCli()
   MsgInfo("my codes!")
RETURN NIL

FUNCTION Html()
   LOCAL cHtml

   TEXT INTO cHtml
   <!DOCTYPE html>
   <html lang="it">
   <head>
       <meta charset="UTF-8">
       <title>Test TWebView</title>
       <style>
           body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0; }
           .post-content-button { list-style: none; padding: 0; display: flex; align-items: center; background-color: #ffffff; border: 1px solid #ccc; border-radius: 5px; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); }
           .post-contenido-button { margin: 10px; }
           .imagen { width: 24px; height: 24px; vertical-align: middle; }
           .tituloboton { font-size: 16px; color: #333; }
           a { text-decoration: none; color: #0078d7; }
           a:hover { text-decoration: underline; color: #005bb5; }
       </style>
   </head>
   <body>
       <ul class="post-content-button">
           <li class="post-contenido-button"><img src="img/test.png" class="imagen" alt="Icona"></li>
           <li class="post-contenido-button">
               <font class="tituloboton">
                   <a href="#" onclick="callHarbourFunction('AppFacCli'); return false;">Añadir nueva factura</a>
               </font>
           </li>
       </ul>

       <script>
           function callHarbourFunction(funcName) {
               var data = { function: funcName };
               var s = SendToFWH(data).then(s => { 
                   alert(s.result);
               }).catch(err => {
                   alert("Errore: " + err); 
               });
           }
       </script>
   </body>
   </html>
   ENDTEXT

RETURN cHtm
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
Posts: 7235
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 16 times

Re: TPanel Left click mouse is possbible?

Post by Silvio.Falconi »

Antonio,
Now run ok

the procedure call RightClickEvent() , this is opened when I click on right click of the mouse into webview

Code: Select all | Expand

#include "FiveWin.ch"

FUNCTION Main()
   LOCAL oWebView := TWebView():New()

   oWebView:SetHtml( Html() )
   oWebView:SetTitle( "Test AppFacCli" )
   oWebView:SetSize( 800, 600 )
   oWebView:Bind( "SendToFWH" )
   oWebView:bOnBind := {|cJson, cCalls| ExecuteFunction(cJson, cCalls, oWebView) }
   oWebView:Run()
   oWebView:Destroy()

RETURN NIL

FUNCTION ExecuteFunction(cJson, cCalls, oWebView)
   LOCAL hData, cFuncName

   // Debug: mostra il JSON ricevuto
   MsgInfo("JSON ricevuto: " + cJson)

   // Decodifica il JSON
   hb_jsonDecode(cJson, @hData)

   // Se hData è un array, prendi il primo elemento
   IF ValType(hData) == "A" .AND. Len(hData) > 0
      hData := hData[1]
   ENDIF

   // Estrai il nome della funzione
   cFuncName := hb_HGetDef(hData, "function", "Nessuna funzione")
   MsgInfo("Funzione estratta: " + cFuncName)

   // Esegui la funzione corrispondente
   IF Upper(cFuncName) == "APPFACCLI"
      AppFacCli()
      oWebView:Return(cCalls, 0, "{ 'result': 'AppFacCli eseguita con successo!' }")
   ELSE
      oWebView:Return(cCalls, 0, "{ 'result': 'Funzione non riconosciuta: " + cFuncName + "' }")
   ENDIF

   RETURN NIL

FUNCTION AppFacCli()
   MsgInfo("my codes!")
   RETURN NIL

Function RightClickEvent()     // this is opened when  I click on right click of the mouse into webview
         MsgInfo("right click!")
   return nil




   FUNCTION Html()
   LOCAL cHtml

   TEXT INTO cHtml
   <!DOCTYPE html>
   <html lang="it">
   <head>
       <meta charset="UTF-8">
       <title>Test TWebView</title>
       <style>
           body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; background-color: #f0f0f0; }
           .post-content-button { list-style: none; padding: 0; display: flex; align-items: center; background-color: #ffffff; border: 1px solid #ccc; border-radius: 5px; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); }
           .post-contenido-button { margin: 10px; }
           .imagen { width: 24px; height: 24px; vertical-align: middle; }
           .tituloboton { font-size: 16px; color: #333; }
           a { text-decoration: none; color: #0078d7; }
           a:hover { text-decoration: underline; color: #005bb5; }
       </style>
   </head>
   <body>
       <ul class="post-content-button">
           <li class="post-contenido-button"><img src="img/test.png" class="imagen" alt="Icona"></li>
           <li class="post-contenido-button">
               <font class="tituloboton">
                   <a href="#" onclick="callHarbourFunction('AppFacCli'); return false;">Aggiungi nuova fattura</a>
               </font>
           </li>
       </ul>

       <script>
           // Funzione per chiamare Harbour
           function callHarbourFunction(funcName) {
               var data = { function: funcName };
               SendToFWH(data).then(s => { 
                   alert(s.result);
               }).catch(err => {
                   alert("Errore: " + err); 
               });
           }

           // Intercetta il clic destro e invia l'evento a Harbour
           document.addEventListener("contextmenu", function(event) {
               event.preventDefault(); // Evita il menu di default del browser
               var data = { function: "RightClickEvent" };
               SendToFWH(data);
           });
       </script>
   </body>
   </html>
   ENDTEXT

RETURN cHtml

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Antonio Linares
Site Admin
Posts: 42716
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 93 times
Been thanked: 103 times
Contact:

Re: TPanel Left click mouse is possbible?

Post by Antonio Linares »

Dear Silvio,

Better use FWH Class TWebView2 instead of Class TWebView as it is much more advanced and it does not require an external DLL

thanks!
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply