Coder Social home page Coder Social logo

Input element request about litehtml HOT 12 OPEN

litehtml avatar litehtml commented on May 22, 2024
Input element request

from litehtml.

Comments (12)

bigfatbrowncat avatar bigfatbrowncat commented on May 22, 2024

I'm sorry for interfering (as I'm not the author), but I want to protect the concept of this library.

There are many browser engines out there - chromiumembedded, gecko and so on. All of them let the user to make forms themselves, actually download the pages from the web and so on... But they are HUGE. And SLOW. :)

LiteHTML is small, fast and easily embeddable. It's main target is to calculate (not render) the visual part and handle output and input events.
If you want tag to be handled, it should be a part of your visualiser (which isn't actually a part of liteHTML). it's up to you to handle a custom tag and create an input field (or a button) cause if liteHTML starts to create buttons for you it would be dependent of some visual component library (such as WinForms or GTK+) and supporting all of them for different platforms would make it huge and possibly slow.

That's only my opinion, but I hope @tordex wouldn't disagree with me...

from litehtml.

DaveM2011 avatar DaveM2011 commented on May 22, 2024

Im not saying that is should be added im pretty sure the issue belong with litebrowser but it would be hugely helpful to have in ethier

from litehtml.

tordex avatar tordex commented on May 22, 2024

Yes, I agree with @bigfatbrowncat, the implementation of the input element must be completely outside litehtml. Generally the method document_container::create_element was created to implement the input tag in the future. Using the document_container::create_element you can overwrite any tag with your own implementation. On the other hands some code can be added into litehtml to help with input tag implementation (like something like notification about new position etc.).

I plan to add the input implementation into litebrowser to test this technology.

from litehtml.

DaveM2011 avatar DaveM2011 commented on May 22, 2024

Awsome thanks be sure to keep me posted even just the basics in litehtml and some sort of editor class in litebrowser i think i could handle the rest and then push it after ive added most of the basics [input,textarea,date,color,spinner] maybe some others there mainly the ones i need to create 😄

from litehtml.

tordex avatar tordex commented on May 22, 2024

Just committed update for litebrowser and litehtml.

In the litehtml I've added the pointer to the document as the parameter of document_container::create_element - you need it to create the custom elements.

The litebrowser now supports the address bar. And this address bar is based on <input> tag. This is just a simple demonstration how to create custom elements and bind them with the real controls.

First we have to implement create_element:

litehtml::element* CToolbarWnd::create_element(const litehtml::tchar_t* tag_name, const litehtml::string_map& attributes, litehtml::document* doc)
{
    if (!t_strcasecmp(tag_name, _t("input")))
    {
        auto iter = attributes.find(_t("type"));
        if (iter != attributes.end())
        {
            if (!t_strcasecmp(iter->second.c_str(), _t("text")))
            {
                if (m_omnibox)
                {
                    m_omnibox->release();
                    m_omnibox = nullptr;
                }

                m_omnibox = new el_omnibox(doc, m_hWnd, this);
                m_omnibox->addRef();
                return m_omnibox;
            }
        }
    }
    return 0;
}

The el_omnibox have a member function update_position:

void el_omnibox::update_position()
{
    litehtml::position pos = litehtml::element::get_placement();
    RECT rcPos;
    rcPos.left = pos.left();
    rcPos.right = pos.right();
    rcPos.top = pos.top();
    rcPos.bottom = pos.bottom();
    m_edit.setRect(&rcPos);
}

You have to call el_omnibox::update_position every time after rendering:

void CToolbarWnd::render_toolbar(int width)
{
    if (m_doc)
    {
        m_doc->render(width);
        m_omnibox->update_position();
    }
}

The m_edit.setRect just updates the real control position. You can replace this with something like MoveWindow or any other function to re-position control.

PS. I've tried to create address bar with the standard Edit (richedit) windows control - this is working, but it is very hard to customize it for visual appearance :( So I've used the custom windowless control I've created later.

from litehtml.

DaveM2011 avatar DaveM2011 commented on May 22, 2024

omg awsome i will give it a go later on in the week thanks a bunch

from litehtml.

DaveM2011 avatar DaveM2011 commented on May 22, 2024

wow awsome work man might be a little buggy but i can work with that got it running and updated in my project in less that a few hours with setting up etc. Im going to spend a little time intergrating it into the main browser theres quite a bit of code to add i see so i will do that first then start adding input types i will let you know how i get on and again good work on this

from litehtml.

gesajt avatar gesajt commented on May 22, 2024

What happen with "input" field? I understand, that it is not part of litehtml, but it is not visible in litebrowser too!

from litehtml.

tordex avatar tordex commented on May 22, 2024

@gesajt the input tag is not implemented in litebrowser.

from litehtml.

gesajt avatar gesajt commented on May 22, 2024

Do you plan to implement it? Since it will be good to have such basic functionality (and so litebrowser can be used for some real sites, not only for visualization).

from litehtml.

blockspacer avatar blockspacer commented on May 22, 2024

see as example implementation https://github.com/blockspacer/qtimgui-wasm-port/blob/feature/litehtml/container_el_inputbox.cpp

from litehtml.

ec1oud avatar ec1oud commented on May 22, 2024

Any plan to get this feature added?

Given that there is no JS, I'd like to be able to turn checkboxes into tabs, for example, as in https://alvarotrigo.com/blog/html-css-tabs/ (the simpler ones, without SVG and so on). So only the checkbox state-changing logic, calculating geometry based on the style, and input handling needs to be in litehtml, right? So far, some such examples (such as https://codepen.io/alvarotrigo/pen/QWqXYmG) even render almost correctly: but they are just not interactive.

Maybe it would be ok to add this piecewise: one input type at a time. I can understand that text-input elements are harder to get working, and more of the work needs to be left to the renderer. For me it's also less important ATM.

from litehtml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.