Git Product home page Git Product logo

tristate's Introduction

Tristate switch control widget

LiveCode widget - tristate switch control (requires LC 10 DP5 or higher)

Current version: 1.0.4t - see changelog
A special thankyou to @BerndN for his invaluable contributions!

Tri-state Switch control (script widget external)

Screenshot 2023-08-27 at 10 34 24

An alternative to the built-in switch widget which offers a trinary instead of binary choice.

  • Optionally show inline labels which are scaled and coloured automatically.
  • Different background colours can be assigned depending on state (left/center/right)
  • A tristateChanged message is sent up the object hierarchy if change needs to be captured for processing. Call within widget's script.
  • Properties are settable directly in the Basic, Contents, Colors and Text panels of its property inspector.

Created with the new script widget facility and requires LiveCode 10.0 DP5 or higher. Use the Extension Manager (Tools menu) to install the widget (the .lce file). After installation an new icon appears in the Tools palette and it's API will appear in the dictionary.

Sourcecode and widget available under MIT licence. To build the extension from source, follow the instructions at the end of the lesson: https://lessons.livecode.com/m/98525/l/1672543-creating-a-script-widget

tristate's People

Contributors

stam66 avatar

Stargazers

 avatar Andres avatar  avatar  avatar Andreas avatar

Watchers

 avatar  avatar

tristate's Issues

Slow initialisation

Creating a widget has a small degree of lag.
Saving a stack with this widget on a card, closing and reopening it causes more noticeable lag, with the widget become visible 1-2 seconds after the the card has opened.

The effect is greatly compounded with multiple widgets; putting 3 such widgets on a card leads to a delay of 4-5 seconds until the widgets are visible (M2 Pro Mac).

Version 1.0.43 does not seem to emit "triStateChanged"

dispatch "triStateChanged" to me with the switchValue of me, the id of me

This is the current version of triStateChange in 1.0.43

Does that work for you?

I have tried but the message does not seem to be emitted. Neither on the card script level nor at the widget script level.

I had tried that version before but it did not work for me then either. That was the reason I dispatched it to the owner of me as in the now out commented version in the Diff does

dispatch "triStateChanged" to the owner of me with the switchValue of me, the id of me

That worked on a the card level.

Change of top line of script to better identify the widget

I suggest to change the top line of your script from

script "com.sk.tristate.livecodescript"

to

script "com.sk.widget.tristate"

This seems to be in line with other script widgets and it shows up better in "tinyDict" and dictionary.

Attempt at adding a handler so that a command can be dispatched to the widget does not work

Added a command:

command setTriState pState
    set the switchValue of the owner of me to pState
    -- set the switchValue of me to pState also doesn't work
end setTriState

The intention is to be able to dispatch a command to the widget, eg:
dispatch "setTriState" to widget "tristate" with "left"
but this doesn't work - and setting a breakpoint at the command doesn't trigger. Perhaps not possible?

Non-persistent properties

Upon saving a stack with a widget whose properties have been modified, closing and re-opening the stack fails to restore the previous set switchValue and it defaults to 'Center'.

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.