Giter Site home page Giter Site logo

Mouse support about ltui HOT 14 CLOSED

tboox avatar tboox commented on May 24, 2024 1
Mouse support

from ltui.

Comments (14)

waruqi avatar waruqi commented on May 24, 2024

Great, thank you very much for your contribution, I will review this patch.

from ltui.

waruqi avatar waruqi commented on May 24, 2024

I have published v2.1 and upload it to luarocks.

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

So... reading through the src files of pdcurses I found out it was only missing a definition to support ncurses' mouse API. I've committed a single line that theoretically would solve it. I still don't have a windows machine set up, so if you would kindly do the testing it would be awesome. Sorry for the delay, I just didn't have the time till now.

from ltui.

waruqi avatar waruqi commented on May 24, 2024

ok, I will test it.

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

Hi, me again
After some work I finally got the mouse working with all view objects (AFAIK) and tests
Since this is an optional feature I thought it would be fit to present it with a customization system.
The ideia is to fool the Lua's loading system by placing a ltui.lua file in a higher priority directory as, for example, the directory where the tests are called. It may also be nice for newcomers (like me) to have an example on how to customize the package to attend individual needs.

https://gist.github.com/laelnasan/92129fecd1e231c6492cd3babd3a0f29

from ltui.

waruqi avatar waruqi commented on May 24, 2024

Great! 👍

Can you help submit pr to directly modify these views of ltui instead of customizing the views.

We can add options.mouseable = true/false to the init() function of each view to selectively enable the mouse feature.

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

That would be a bit of a grind, because every call to an init() of a child of panel would have to be changed, specially the instantiation of the objects inside dialogs would have to be conditioned to the property.
In the solution I presented, I change the behaviour of the classes at loading time so that all children inherit the changes automatically.
Not saying it cant be done, but I can't see an easy way to do it

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

I think I may have found a workaround... I just don't know if it fits the coding style: to use a metatable to dynamically load the ltui/* modules and set a global ltui.options

Then one could write something like:

local ltui = require('ltui')
ltui.options = {mouseable = true}

local app   = ltui.application
local label = ltui.label
...

from ltui.

waruqi avatar waruqi commented on May 24, 2024

ltui.options = {mouseable = true}

like this:

-- mark as selectable
self:option_set("selectable", true)
-- enable progress
self:option_set("progress", true)

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

yes, but that is a option of the instantiated object, right? not the class per se. and how do we identify when the entire application is mouseable or not?

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

ow, I think I get it now

from ltui.

waruqi avatar waruqi commented on May 24, 2024

yes, but that is a option of the instantiated object, right? not the class per se. and how do we identify when the entire application is mouseable or not?

Each view component should allow the user to control whether it can enable the mouse if this view support mouse.

from ltui.

laelnasan avatar laelnasan commented on May 24, 2024

but if the default behaviour doesn't take a global property then the user must modify every single object instantiated to get it working, is that it? I am not trying to convince you, just making sure I understand the idea.

from ltui.

waruqi avatar waruqi commented on May 24, 2024

but if the default behaviour doesn't take a global property then the user must modify every single object instantiated to get it working, is that it? I am not trying to convince you, just making sure I understand the idea.

We can also use application:option_set() and view:application():option() to set/get global default option to all sub-views.

from ltui.

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.