WebView - Create beautiful, cross-platform desktop apps with Ring and web technologies

496 views
Skip to first unread message

Youssef Saeed

unread,
Jul 22, 2025, 2:10:46 PM7/22/25
to The Ring Programming Language
Hello everyone,

I'm thrilled to share the release of WebView—a powerful new Ring library for building modern, cross-platform desktop applications! With WebView, you can leverage web technologies for your frontend while using Ring as the backend, all through a simple and intuitive API.

Showcase:

Screenshot From 2025-07-22 20-44-14.pngApplication DemoScreenshot From 2025-07-22 21-00-07.png

Key Features:
- Cross-Platform: Develop for Windows, macOS, Linux, and FreeBSD from a single codebase.
- Modern UI: Design interfaces using familiar web technologies.
- Two-Way Binding: Effortlessly call Ring functions from JavaScript and vice versa.
- Easy to Use: Get started quickly with a clean, straightforward API.

Installation

Install via RingPM:

ringpm install webview from ysdragon

For platform-specific prerequisites (Linux, Windows, FreeBSD), please refer to the instructions on our GitHub repository.

Learn More

- GitHub Repository
- API Reference
- Examples Directory — Find many practical examples to help you get started.

Contributions are welcome!

Have ideas or found a bug? Please open an issue or submit a pull request on GitHub. 

Your feedback is greatly appreciated!

Hope you find WebView useful!

Best regards,  
Youssef

Mansour Ayouni

unread,
Jul 22, 2025, 2:20:16 PM7/22/25
to Youssef Saeed, The Ring Programming Language
Hello Youssef,

CONGRATULATIONS!!!

I'm so happy and excited for you, and all of us with this project!

We needed it to bridge Ring with the web, and I particularly need it in a critical moment of my relalword project with StzLib, where my customer is asking for simple web interfaces to test several aspects of his business API( written in Ring and StzLib).

I'll test it and I will let you know.

All the best,
Mansour



--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/15e23352-9546-4694-a8e3-8a427030eaf5n%40googlegroups.com.
Message has been deleted

Youssef Saeed

unread,
Jul 22, 2025, 2:42:58 PM7/22/25
to The Ring Programming Language
Hello Mansour,

Thank you so much for your kind words!

It's fantastic to hear that WebView comes at a critical time for your project with StzLib. Knowing that it can help bridge the gap for your customer's business API is exactly the kind of feedback I was hoping for. This is precisely the kind of real-world application I was hoping to support with this library.

I'm really looking forward to hearing how your testing goes. Please don't hesitate to reach out if you have any questions or feedback. It would be invaluable.

Best regards,
Youssef

Ilir Liburn

unread,
Jul 22, 2025, 2:56:41 PM7/22/25
to The Ring Programming Language
Hello Youssef,

Congratulations on the new library. I'm getting following error:

Error: Unsupported architecture: x86

Meaning, 32 bit is not supported?

Greetings,
Ilir
Message has been deleted

Mahmoud Fayed

unread,
Jul 22, 2025, 4:20:35 PM7/22/25
to The Ring Programming Language
Hello Youssef

This is a very wonderful package that contains a great extension and beautiful samples
I enjoyed running each sample in the package :D 

The sample (14_live_markdown_editor.ring) produce error (Error (E9) : Can't open file markdown.ring)
The sample ( 24_ringfetch.ring) produce error (Error (E9) : Can't open file SysInfo.ring)

This happens if markdown and sysinfo packages are not installed

Three quicks solutions:

(1) Add (SysInfo) and (Markdown) packages to WebView package file): webview/package.ring at main · ysdragon/webview
So, installing WebView will install Markdown and SysInfo packages too

(2) If you would like to avoid step (1) - Add system("ringpm install sysinfo") and system("ringpm install markdown") to related samples

(3) If you don't like solution (1) or (2) create another package for these samples or isolate them in specific folder in WebView package with README file to point to the need of the required packages

My favorite sample is: 22_chat_bot.ring

ringbot.png

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 22, 2025, 4:20:53 PM7/22/25
to The Ring Programming Language
Hello Ilir,

Thank you so much for your kind words!

>I'm getting following error:
Error: Unsupported architecture: x86
Meaning, 32 bit is not supported?

Regarding the error you encountered (Unsupported architecture: x86), you are correct. It indicated that 32-bit architecture was not initially supported.

I have just pushed an update to add support for Windows x86. Could you please try removing the package and then installing it again? This should resolve the issue.

If the problem persists, please let me know which operating system you are using so I can investigate further.

Best regards,
Youssef

Ilir Liburn

unread,
Jul 22, 2025, 4:30:10 PM7/22/25
to The Ring Programming Language
Hello Youssef,

You're Welcome. After reinstalling the package:

Error: WebView library not found! 
Expected location: C:\ring\bin\..\\tools\\ringpm\\packages\\webview\\lib\\windows\\i386\\ring_webview.dll
Please ensure the library is built for your platform (windows/i386)          

Greetings,
Ilir

Ilir Liburn

unread,
Jul 22, 2025, 4:46:22 PM7/22/25
to The Ring Programming Language
Hello Youssef,

i386 directory is not created, therefore missing ring_webview.dll in 32 bit version. I tested it by using development console in Windows 11.

Greetings,
Ilir

Mahmoud Fayed

unread,
Jul 22, 2025, 7:45:02 PM7/22/25
to The Ring Programming Language
Hello Ilir

If you checked the package file you will notice that the package install amd64 folder files on windows

So, try to get the 32bit version from this folder:  webview/lib/windows/i386 at main · ysdragon/webview

Greetings,
Mahmoud

Ilir Liburn

unread,
Jul 22, 2025, 8:32:34 PM7/22/25
to The Ring Programming Language
Hello Mahmoud,

package installer downloads

Download File : lib/windows/amd64/ring_webview.dll
Download File : lib/windows/arm64/ring_webview.dll  

AMD64 and ARM64 are installed, but i386/x86 is missing. I think best user experience is when libraries are preinstalled instead of searching for missing ones.

Alternatively, user might be instructed to build library if source code is available.

Greetings,
Ilir

Mahmoud Fayed

unread,
Jul 22, 2025, 9:02:06 PM7/22/25
to The Ring Programming Language
Hello Ilir

Yes, I agree with you, I am just sharing a quick solution with you until our friend Youssef update the package.

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 23, 2025, 1:18:46 AM7/23/25
to The Ring Programming Language
Hello Mahmoud,


Thank you so much for your kind words!
I'm glad to hear that you enjoyed the examples.


>The sample (14_live_markdown_editor.ring) produce error (Error (E9) : Can't open file markdown.ring)
The sample ( 24_ringfetch.ring) produce error (Error (E9) : Can't open file SysInfo.ring)

This happens if markdown and sysinfo packages are not installed

Three quicks solutions:

(1) Add (SysInfo) and (Markdown) packages to WebView package file): webview/package.ring at main · ysdragon/webview
So, installing WebView will install Markdown and SysInfo packages too

(2) If you would like to avoid step (1) - Add system("ringpm install sysinfo") and system("ringpm install markdown") to related samples

(3) If you don't like solution (1) or (2) create another package for these samples or isolate them in specific folder in WebView package with README file to point to the need of the required packages

Thank you again for your suggestions. I have followed solution 1.

Best regards,
Youssef

Youssef Saeed

unread,
Jul 23, 2025, 1:21:38 AM7/23/25
to The Ring Programming Language
Hello Ilir,

Error: WebView library not found! 
Expected location: C:\ring\bin\..\\tools\\ringpm\\packages\\webview\\lib\\windows\\i386\\ring_webview.dll
Please ensure the library is built for your platform (windows/i386)      

Sorry for the frustration. I have now added the Windows x86 lib to the package info list, so you can remove the package and install it again.

Best regards,
Youssef

Youssef Saeed

unread,
Jul 23, 2025, 1:28:29 AM7/23/25
to The Ring Programming Language
Hello Ilir,


> AMD64 and ARM64 are installed, but i386/x86 is missing. I think best user experience is when libraries are preinstalled instead of searching for missing ones.

Yes, that has been fixed.


> Alternatively, user might be instructed to build library if source code is available.

Thank you for the suggestion. I have added a message to the install script that directs users to our README.md, where they can find instructions on how to build the library themselves if a pre-built version is not available for their OS and architecture.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 4:44:47 AM7/23/25
to The Ring Programming Language
Hello Youssef

Thank you very much for the update :D



Some suggestions (for the future once you have the time and if they are acceptable to you according to your design):

(1) Installing webview.ring in ring/bin/load folder instead of ring/bin folder

(2) Supporting Ring2EXE by adding a library definition file in this folder: ring/tools/ring2exe/libs at master · ring-lang/ring

(3) To quickly apply (1) and (2)  
Please check the JsonLib package file in this folder: ringpackages/jsonlib: JSONLib library for the Ring programming language

The package could install files in different Ring folders by using the :ringFolderFiles option: jsonlib/package.ring at master · ringpackages/jsonlib

The idea is that we expect samples in ring/samples/UsingWebview folder which contains samples from different packages: ring/samples at master · ring-lang/ring

(4) Instead of using bind() method many times as in this example: webview/examples/13_to_do_list.ring at main · ysdragon/webview
Adding an optional method like bindMany() which get a list like this 
[  ["getInitialTodos", :handleGetInitialTodos], 
["addTodo", :handleAddTodo],
# ...
# ...
]
The idea could be to define such lists at the top of the file (if we want) then reuse it when calling bindMany() 
And bindMany() could be optional if we used a specific global variable name like aBindList 
Where the WebView class could check this using isGlobal(): Reflection and Meta-programming — Ring 1.23.0 documentation

(5) You could avoid using braceEnd() to call destroy(): webview/src/webview.ring at main · ysdragon/webview
 
The idea from using RING_API_RETMANAGEDCPOINTER is that we can execute (Any Function) when Ring delete an object 
We can change (ring_webview_free) and write any function that you can define (will get Ring State, Object Pointer) as parameter
And this C function could call destroy

This way we can use braces multiple times with WebView object without having implicit call to destroy () method
Also, we can use the dot operator instead of using braces and still Ring can destroy the object when this is necessary

Youssef Saeed

unread,
Jul 23, 2025, 8:44:46 AM7/23/25
to The Ring Programming Language
Hello Mahmoud,

Thank you for adding our project to the RingPM registry and the Ring Website. We also appreciate your excellent suggestions.

I have implemented them in the following commits:

Suggestions 1, 2, and 3: Addressed in commits: 8ba2c20 9142c3d  using our custom install.ring script.

Suggestion 4: Implemented in commit: c2e0e4c

Suggestion 5: Addressed with your recommended approach in commits: db0ef37 c8f05b4

Thank you once more for your suggestions.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 9:07:52 AM7/23/25
to The Ring Programming Language
Hello Youssef

Thank you very much for this wonderful update

Just another little suggestion: Using bindMany(NULL) and new WebView(true, NULL) could be avoided

For example, we can rewrite the next code

Class WebView

_pWebView
_bindings = []
_isDestroyed = false

func init(debug, window)
self._pWebView = webview_create(debug, window)
if isNull(self._pWebView) or not isPointer(self._pWebView)
raise("Failed to create webview instance.")
ok

(1) To avoid bindMany(NULL) we just use

func init(debug, window)
self._pWebView = webview_create(debug, window)
if isNull(self._pWebView) or not isPointer(self._pWebView)
raise("Failed to create webview instance.")
ok
                bindMany(NULL)

(2) And to avoid WebView(true, NULL) 
we set true, NULL as the default parameters from the class 

# webview.ring

aWebViewConfig = [
    :debug = true  ,
    :window = NULL
]

Class WebView

_pWebView
_bindings = []
_isDestroyed = false

func init
self._pWebView = webview_create( aWebViewConfig [:debug], aWebViewConfig[:window])
if isNull(self._pWebView) or not isPointer(self._pWebView)
raise("Failed to create webview instance.")
ok
                bindMany(NULL)
                

This way, in application code that uses the library we just use
oWebView = new WebView()

and if we want to change the parameters (rare case)
we do this like
 aWebViewConfig [:debug] = false 

Greetings,
Mahmoud

Bert Mariani

unread,
Jul 23, 2025, 12:11:11 PM7/23/25
to The Ring Programming Language
Hello Youssef

Slick, Polished and Impressive !!
Something we are all Eager and Happy to See  Implemented, and Released !!
Everything worked on my Windows-11  64bit.

Best Regards
Bert Mariani

Youssef Saeed

unread,
Jul 23, 2025, 12:20:08 PM7/23/25
to The Ring Programming Language
Hello Mahmoud,

Thank you for this excellent suggestion! It's a fantastic idea for simplifying the API.

I have now applied this change (e281626). It really cleans up the user-facing code.

Thanks again!

Best regards,
Youssef

Youssef Saeed

unread,
Jul 23, 2025, 12:21:54 PM7/23/25
to The Ring Programming Language
Hello Bert,

Thank you for the very kind words! I'm delighted to hear you find the work "Slick, Polished and Impressive."

I also really appreciate you taking the time to confirm that it works perfectly on your Windows 11 64-bit system. That's fantastic and very valuable feedback.

Best Regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 1:37:45 PM7/23/25
to The Ring Programming Language
Hello Youssef

This is very nice, Thanks for the updates :D

Just two little comments:

(1) The sample (03_local_html.ring) doesn't work after the latest updates
And produce the next error message:

Line 11 Error (R20) : Calling function with extra number of parameters

in file B:/ring/samples/UsingWebView/03_local_html.ring

Because of this line: oWebView = new WebView(0, NULL) 


(2) A lot of samples call the destroy() method that we no longer need to call 
Attached a report about these samples using (Find in Files) tool

destroy.png

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 23, 2025, 1:56:13 PM7/23/25
to The Ring Programming Language
Hello Mahmoud,

Thank you so much for the reports! I have applied the fixes/changes in these commits: 7c229e8 c77de7a

Best Regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 2:07:34 PM7/23/25
to The Ring Programming Language
Hello Youssef

Thanks for the updates, works as expected :D

Just a little comment
In the code we have aWebViewConfig

webconfigcode.png

But in the samples the variable name is written as (cWebViewConfig)
i.e. the first letter (a) is replaced by the (c) letter
Attached a report by Find in Files application

webconfig.png1

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 23, 2025, 2:22:39 PM7/23/25
to The Ring Programming Language
Hello Mahmoud,

Thanks for the feedback, and glad it's working for you!

Good catch on that typo – I've fixed it now.

Best Regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 2:26:18 PM7/23/25
to The Ring Programming Language
Hello Youssef

Thanks for the update :D This is GREAT PACKAGE for Ring developers :D
Waiting for your next contributions (packages/tutorials/deploying web/HTTPLib apps in the cloud, etc.)

Keep up the GREAT WORK :D

Greetings,
Mahmoud


Youssef Saeed

unread,
Jul 23, 2025, 2:36:56 PM7/23/25
to The Ring Programming Language
Hello Mahmoud,

Thanks so much for the kind words! I'm really happy to hear you're finding the package useful.

Your support is a great motivation. More to come, for sure!

Best Regards,
Youssef

Mahmoud Fayed

unread,
Jul 23, 2025, 5:39:23 PM7/23/25
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Azzeddine Remmal

unread,
Jul 29, 2025, 7:40:34 AM7/29/25
to The Ring Programming Language
Hello Youssef

I am trying to implement an example using the WebView library.
When I use OOP, errors occur.

# ===================================================================
# Chat Application Example - Using WebView with Ring and JavaScript
# ===================================================================

load "webview.ring"
load "jsonlib.ring"
load "stdlib.ring"

# تهيئة WebView مع الربط بين Ring و JavaScript

oChatApp = new ChatApp()

class ChatApp

oWebView = new WebView()
# تهيئة النافذة وربط الدوال
oWebView {
    setTitle("تطبيق المحادثة")
    setSize(800, 600, WEBVIEW_HINT_NONE)
   
    # ربط دالة Ring مع JavaScript
    bind("sendMessage", :sendMessage)
   
    # تعيين محتوى HTML
    setHtml(`
        <!DOCTYPE html>
        <html dir="rtl" lang="ar">
        <head>
            <meta charset="UTF-8">
            <title>تطبيق المحادثة</title>
            <style>
                body {
                    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
                    margin: 0;
                    padding: 20px;
                    background: #f0f2f5;
                }
                .chat-container {
                    max-width: 600px;
                    margin: 0 auto;
                    background: white;
                    border-radius: 10px;
                    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
                    padding: 20px;
                }
                .messages {
                    height: 400px;
                    overflow-y: auto;
                    padding: 10px;
                    border: 1px solid #ddd;
                    border-radius: 5px;
                    margin-bottom: 20px;
                }
                .message {
                    margin: 10px 0;
                    padding: 10px;
                    border-radius: 10px;
                    max-width: 80%;
                }
                .user-message {
                    background: #0084ff;
                    color: white;
                    margin-left: auto;
                }
                .ai-message {
                    background: #f0f0f0;
                    margin-right: auto;
                }
                .input-container {
                    display: flex;
                    gap: 10px;
                }
                input {
                    flex: 1;
                    padding: 10px;
                    border: 1px solid #ddd;
                    border-radius: 5px;
                    font-size: 16px;
                }
                button {
                    padding: 10px 20px;
                    background: #0084ff;
                    color: white;
                    border: none;
                    border-radius: 5px;
                    cursor: pointer;
                }
                button:hover {
                    background: #0073e6;
                }
            </style>
        </head>
        <body>
            <div class="chat-container">
                <div class="messages" id="messages">
                    <div class="message ai-message">
                        مرحباً! كيف يمكنني مساعدتك اليوم؟
                    </div>
                </div>
                <div class="input-container">
                    <input type="text" id="messageInput" placeholder="اكتب رسالتك هنا..."
                           onkeypress="if(event.key === 'Enter') sendMessageToRing()">
                    <button onclick="sendMessageToRing()">إرسال</button>
                </div>
            </div>

            <script>
                async function sendMessageToRing() {
                    const input = document.getElementById('messageInput');
                    const message = input.value.trim();
                   
                    if (!message) return;
                   
                    // إضافة رسالة المستخدم
                    addMessage(message, 'user-message');
                    input.value = '';
                   
                    try {
                        // استدعاء دالة Ring
                        const response = await window.sendMessage(message);
                       
                        // إضافة رد الذكاء الاصطناعي
                        addMessage(response, 'ai-message');
                    } catch (error) {
                        addMessage('عذراً، حدث خطأ في معالجة الرسالة', 'ai-message');
                    }
                }

                function addMessage(text, className) {
                    const messages = document.getElementById('messages');
                    const div = document.createElement('div');
                    div.className = 'message ' + className;
                    div.textContent = text;
                    messages.appendChild(div);
                    messages.scrollTop = messages.scrollHeight;
                }
            </script>
        </body>
        </html>
    `)
   
    run()
}
# تعريف الدوال التي سيتم ربطها مع JavaScript
func sendMessage(id, req)
    try
        aParams = json2list(req)
        cMessage = aParams[1][1]
       
        # هنا يمكنك معالجة الرسالة (مثلاً إرسالها للذكاء الاصطناعي)
        cResponse = "مرحباً! تلقيت رسالتك: " + cMessage
        ? cResponse
        # إرجاع الرد إلى JavaScript
        oWebView.wreturn(id, WEBVIEW_ERROR_OK, '"' + cResponse + '"')
       
    catch
        oWebView.wreturn(id, WEBVIEW_ERROR_OK, '"حدث خطأ في معالجة الرسالة"')
    done



Output :

λ ring chat_app.ring                                                                          
                                                                                             
Line 50 Error (R3) : Calling Function without definition: sendmessage                        
In webview_run() In method run() in file C:\ring\tools\ringpm\packages\webview\src/webview.rin
g                                                                                            
                                                                                             
Called from line 142 in file chat_app.ring [0729/121922.221:ERROR:ui\gfx\win\window_impl.cc:12
4] Failed to unregister class Chrome_WidgetWin_0. Error = 1412  
                             
  See also   

my regards, Azzeddine

Mahmoud Fayed

unread,
Jul 29, 2025, 8:57:56 AM7/29/25
to The Ring Programming Language
Hello Azzeddine

RingWebView is designed to call Functions (Not Methods) where the implementation pass (id, req) to this function through the Stack (Not by evaluating Ring code)

To use methods, create a wrapper function that create the object then call the method and pass the parameters

To automate this process using reflection and meta-programming, see this example (library + test program)

aWebObjects = []

new test { start() }

func Method oObj,cName
aWebObjects + ref(oObj)
cCode = `
cFunc = func (id, req) {
aWebObjects[#{id}].#{cName}(id,req)
}
`
cCode = substr(cCode,"#{id}",""+len(aWebObjects))
cCode = substr(cCode,"#{cName}",cName)
eval(cCode)
return cFunc


class test

func start

cFuncName = Method(self,:MyMethod)
call cFuncName(10,"test")

func MyMethod id, req
? "Hello from the Method!"
? "ID  = " + id
? "req = " + req 

Output:

Hello from the Method!
ID  = 10
req = test

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 29, 2025, 4:40:51 PM7/29/25
to The Ring Programming Language
Hello Azzeddine,

As Mahmoud mentioned, RingWebView is designed to call functions rather than methods. Acting on his workaround, I've added a new example that shows how to use class methods as callbacks.

You can find it here: examples/34_using_class_methods.ring - ysdragon/webview

Best regards,
Youssef
On Tuesday, July 29, 2025 at 2:40:34 PM UTC+3 Azzeddine Remmal wrote:

Youssef Saeed

unread,
Jul 29, 2025, 4:45:16 PM7/29/25
to The Ring Programming Language
Hello Mahmoud,

This is a brilliant solution, thank you! The way you automated the process with a meta-programming wrapper is fantastic.

The meta-programming example you provided is an absolutely brilliant and elegant way to solve the problem. This is incredibly helpful not just for Azzeddine, but for the project as a whole.

Best regards,
Youssef

Azzeddine Remmal

unread,
Jul 29, 2025, 5:16:44 PM7/29/25
to The Ring Programming Language
Hello Youssef

# ===================================================================
# WebView Method Wrapper - حل لاستدعاء الطرق عبر RingWebView
# ===================================================================
load "webview.ring"

# مصفوفة لحفظ مراجع الكائنات
aWebObjects = []

# ===================================================================
# دالة إنشاء مُغلف للطرق - الحل الأساسي
# ===================================================================
func Method oObj, cMethodName
    # إضافة الكائن إلى المصفوفة
    aWebObjects + oObj
    nObjectId = len(aWebObjects)
   
    # إنشاء كود الدالة المُغلفة
    cCode = `
        cFunc = func (id, req) {
            return aWebObjects[#{id}].#{method}(id, req)
        }
    `
   
    # استبدال المتغيرات
    cCode = substr(cCode, "#{id}", "" + nObjectId)
    cCode = substr(cCode, "#{method}", cMethodName)
   
    # تقييم الكود وإرجاع الدالة
    eval(cCode)
    return cFunc

# ===================================================================
# دالة مساعدة لربط طرق الكائن بـ WebView
# ===================================================================
func BindObjectMethods oWebView, oObject, aMethodsList
    aBindList = []
   
    for aMethodInfo in aMethodsList
        cJSName = aMethodInfo[1]      # اسم الدالة في JavaScript
        cMethodName = aMethodInfo[2]  # اسم الطريقة في الكائن
       
        # إنشاء دالة مُغلفة للطريقة
        cWrapperFunc = Method(oObject, cMethodName)
       
        # إضافة إلى قائمة الربط
        aBindList + [cJSName, cWrapperFunc]
    next
   
    # ربط جميع الدوال مع WebView
    for aBinding in aBindList
        cJSName = aBinding[1]
        cWrapperFunc = aBinding[2]
        oWebView.bind(cJSName, cWrapperFunc)
        see "Bound method: " + cJSName + nl
    next
   
    return aBindList

# ===================================================================
# كلاس مساعد لإدارة ربط الطرق
# ===================================================================
class WebViewMethodBinder
   
    aObjects = []
   
    func bindMethod oWebView, cJSName, oObject, cMethodName
        # حفظ الكائن
        this.aObjects + oObject
        nObjectIndex = len(this.aObjects)
       
        # إنشاء دالة مُغلفة باستخدام Method
        cWrapperFunc = Method(oObject, cMethodName)
       
        # ربط الدالة مع WebView
        oWebView.bind(cJSName, cWrapperFunc)
       
        return true
   
    func bindMultipleMethods oWebView, oObject, aMethodsList
        for aMethodInfo in aMethodsList
            cJSName = aMethodInfo[1]
            cMethodName = aMethodInfo[2]
            this.bindMethod(oWebView, cJSName, oObject, cMethodName)
        next



# ===================================================================
# اختبار مبسط لنظام ربط الطرق
# ===================================================================

load "src/webview_method_wrapper.ring"
load "jsonlib.ring"
load "stdlib.ring"
# تشغيل الاختبارات
runSimpleTests()

# ===================================================================
# تشغيل الاختبارات
# ===================================================================
func runSimpleTests()
    see "بدء الاختبارات المبسطة..." + nl + nl
   
    testBasicWrapper()
    testSimpleBinding()
   
    see "=== انتهت جميع الاختبارات المبسطة بنجاح! ===" + nl

# ===================================================================
# اختبار الحل الأساسي فقط
# ===================================================================
func testBasicWrapper()
    see "=== اختبار الحل الأساسي ===" + nl
   
    # إنشاء كائن تجريبي
    oTestObject = new SimpleTestClass
   
    # إنشاء دالة مُغلفة للطريقة
    cWrapperFunc = Method(oTestObject, "testMethod")
   
    # اختبار استدعاء الدالة المُغلفة
    see "استدعاء الدالة المُغلفة..." + nl
    call cWrapperFunc(1, "test request")
   
    see "تم الاختبار الأساسي بنجاح!" + nl + nl

# ===================================================================
# اختبار ربط متعدد مبسط
# ===================================================================
func testSimpleBinding()
    see "=== اختبار الربط المتعدد ===" + nl
   
    # إنشاء كائن تجريبي
    oTestObject = new SimpleTestClass
   
    # تعريف قائمة الطرق
    aMethodsList = [
        ["testMethod", "testMethod"],
        ["anotherMethod", "anotherMethod"]
    ]
   
    # محاكاة WebView بسيطة
    oMockWebView = new SimpleWebView
   
    # ربط الطرق
    aBindList = BindObjectMethods(oMockWebView, oTestObject, aMethodsList)
   
    see "تم ربط " + len(aBindList) + " طريقة بنجاح!" + nl
    for aBinding in aBindList
        see "  - " + aBinding[1] + nl
    next
   
    see "تم اختبار الربط المتعدد بنجاح!" + nl + nl

# ===================================================================
# كلاس تجريبي بسيط
# ===================================================================
class SimpleTestClass
   
    func testMethod id, req
        see "تم استدعاء testMethod!" + nl
        see "ID: " + id + nl
        see "Request: " + req + nl
        return "نجح الاختبار!"
   
    func anotherMethod id, req
        see "تم استدعاء anotherMethod!" + nl
        see "ID: " + id + nl
        see "Request: " + req + nl
        return "نجح اختبار آخر!"

# ===================================================================
# كلاس WebView بسيط للاختبار
# ===================================================================
class SimpleWebView
   
    func bindMany aBindList
        see "SimpleWebView: ربط " + len(aBindList) + " دالة" + nl
        for aBinding in aBindList
            see "  - ربط: " + aBinding[1] + nl
        next
   
    func bind cName, cFunc
        see "SimpleWebView: ربط دالة واحدة: " + cName + nl


Mahmoud Fayed

unread,
Jul 29, 2025, 5:55:38 PM7/29/25
to The Ring Programming Language
Hello Youssef

>> "This is a brilliant solution, thank you! The way you automated the process with a meta-programming wrapper is fantastic."

Thanks for your kind words :D

Greetings,
Mahmoud

Azzeddine Remmal

unread,
Jul 29, 2025, 6:24:36 PM7/29/25
to The Ring Programming Language
Hello Mahmoud.
Thanks for the great solution, but I haven't been able to get the app to run due to Jason issues. I wanted to contribute to the library, and the best way to contribute is to use it or build a complex project with it.
Sketch.png
Regards.

Mahmoud Fayed

unread,
Jul 29, 2025, 6:47:25 PM7/29/25
to The Ring Programming Language
Hello Azzeddine

Thanks for sharing the project source code :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jul 30, 2025, 6:31:54 AM7/30/25
to The Ring Programming Language
Hello

This is another implementation for the Method() function using Print2Str() function
And using Return inside Eval() instead of the cFunc variable

aWebObjects = []


func Method oObj,cName
aWebObjects + ref(oObj)
return eval(print2str(`
return func (id, req) { aWebObjects[#{len(aWebObjects)}].#{cName}(id,req) }
`))

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 30, 2025, 7:34:04 AM7/30/25
to The Ring Programming Language
Hello Mahmoud,

Thank you very much for sharing this implementation of the Method() function.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jul 30, 2025, 7:50:02 AM7/30/25
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 31, 2025, 10:04:56 AM7/31/25
to The Ring Programming Language
Hello Mahmoud,

Based on your examples, I have added support for calling object methods directly in this commit.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jul 31, 2025, 11:23:26 AM7/31/25
to The Ring Programming Language
Hello Youssef

Very nice updates, Thanks for sharing :D

Note: the sample that uses Ring threads to execute javascript code that increase a counter is not working on Windows
i.e. the counter value is always 0.

Looks like updating WebView from another threads is not supported. 

Greetings,
Mahmoud

Youssef Saeed

unread,
Jul 31, 2025, 11:42:20 AM7/31/25
to The Ring Programming Language
Hello Mahmoud,

Thank you for your kind words.


> Note: the sample that uses Ring threads to execute javascript code that increase a counter is not working on Windows
i.e. the counter value is always 0.

Looks like updating WebView from another threads is not supported. 

I have tested it on Linux, and it works with no issues. I will investigate this further.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jul 31, 2025, 12:22:46 PM7/31/25
to The Ring Programming Language
Hello Youssef

Thanks for the information :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Aug 5, 2025, 2:24:22 PM8/5/25
to The Ring Programming Language
Hello Youssef

Could you please update WebView to use dynamic linking on Windows?

This is important to avoid the need to rebuild the extensions when custom changes are made to Ring VM (without changing the API)

Greetings,
Mahmoud

Youssef Saeed

unread,
Aug 5, 2025, 3:59:21 PM8/5/25
to The Ring Programming Language
Hello Mahmoud,

Thank you for the suggestion regarding dynamic linking for the WebView extension on Windows.

The reason we're currently linking statically on Windows is that the "ring_webview_bind_callback" function directly calls several VM functions:

- ring_vm_fetch()
- ring_vm_loadfunc2()
- ring_vm_call2()

These functions are not part of the public Ring API (they are not decorated with the RING_API macro).

Consequently, if we tried to link the extension dynamically against ring.dll on Windows, the linker would fail with "unresolved external symbol" errors for these functions. Static linking against ringstatic.lib is currently the only way to resolve these references.

Best regards,
Youssef

Mahmoud Fayed

unread,
Aug 5, 2025, 5:02:09 PM8/5/25
to The Ring Programming Language
Hello Youssef

Thanks for the information
We can improve Ring VM API to handle such cases :D
Added to my To-Do list.

Greetings,
Mahmoud

Youssef Saeed

unread,
Aug 6, 2025, 11:33:46 AM8/6/25
to The Ring Programming Language
Hello Mahmoud,

Following up on the threading issue you reported on Windows. I believe I've found a workaround to fix it.

The necessary changes are in these two commits: 1a2675e 7ffd5a7

Could you please try the latest version of the library and test the multi-threaded counter example again to confirm if it now works as expected on your end?

Thanks again for your help!

Best regards,
Youssef

Mahmoud Fayed

unread,
Aug 6, 2025, 11:38:21 AM8/6/25
to The Ring Programming Language
Hello Youssef

This is wonderful :D

I have already updated the package, tested the sample and everything in this sample works as expected :D

Screen Shot:

threadsandwebview.png 

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Youssef Saeed

unread,
Aug 6, 2025, 11:50:46 AM8/6/25
to The Ring Programming Language
Hello Mahmoud,

Wonderful! Thanks a lot for confirming the fix works on Windows. Your feedback was a great help.

Best regards,
Youssef

Mahmoud Fayed

unread,
Aug 6, 2025, 11:59:38 AM8/6/25
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Aug 15, 2025, 11:38:10 PM8/15/25
to The Ring Programming Language
Hello Youssef

>> "These functions are not part of the public Ring API (they are not decorated with the RING_API macro)."

The RING_API macro is used now with these functions in Ring 1.24

Note: Ring 1.24 C API comes with some changes that have an effect on WebView, please read this topic: A message for Ring extensions developers (Little changes in Ring C API)

Greetings,
Mahmoud 

Youssef Saeed

unread,
Aug 16, 2025, 1:08:17 AM8/16/25
to The Ring Programming Language
Hello Mahmoud,

Thank you for these important changes and for letting us know about them. This post is very helpful.

Best regards,
Youssef

Mahmoud Fayed

unread,
Aug 16, 2025, 7:31:36 AM8/16/25
to The Ring Programming Language
Hello Youssef

You are welcome :D

Greetings,
Mahmoud

Mahmoud Fayed

unread,
Jun 2, 2026, 4:25:05 AM (2 days ago) Jun 2
to The Ring Programming Language
Hello Youssef

When testing WebView package with Ring 1.27 I noticed that the samples crash starting from sample no. 4 when I click on any button

But when I build WebView from source code, I don't see this problem and all samples works as expected

Tested using Windows 11 and Ring 1.27 (64 bit)

Youssef Saeed

unread,
Jun 2, 2026, 8:40:56 AM (2 days ago) Jun 2
to The Ring Programming Language
Hello Mahmoud,

Thank you for reporting this. I investigated the issue and found that it was caused by a stale master branch that wasn't synced with main (which is the default branch).

I fixed this by removing the stale master branch and adding the remote branch and folder to package.ring.

I also believe this needs to be addressed on the RingPM side, as I already had the main branch specified in package.ring.

Best regards,
Youssef

Mahmoud Fayed

unread,
Jun 2, 2026, 11:28:25 AM (2 days ago) Jun 2
to The Ring Programming Language
Hello Youssef

Thank you very much for the update
It works as expected :D

Keep up the GREAT WORK :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages