Making Custom Lint for Kotlin Code

This blog is my learning on writing Custom Lint for Kotlin code, and provide a working example as reference. The learning came from extracting information from various sources, which I will provide…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Three input element properties that I discovered while reading MDN

So here we go!

This is Dan’s Tweet example — let’s have a quick look and assume you have some HTML and query an input element which has a value attribute (attributes are defined in the HTML whereas properties belong to JavaScript objects) defined.

You can now grab this element and start tinkering around with it.

As you see that the value defined in the attribute value is initially reflected in the element property value. That makes total sense to me. When you now change value, you can still access the "initial value" using defaultValue (for checkboxes defaultChecked is also available). Pretty cool!

The indeterminate property is a fascinating one. Did you know that checkboxes can have an additional visual state other than checked and not checked? indeterminate is a property (there is no attribute for it) that you can use to put this little dash into a checkbox that you may have seen every now and then.

indeterminate doesn't work only for checkboxes though. It also can be used for radio buttons and progress elements. Let's take a group of radio buttons in which no radio button is selected. When you're not preselecting one element in a group of radio buttons none of them is selected and also none of them is not selected – thus all of them are in indeterminate state.

What’s cool is, that you can also use the CSS pseudo class :indeterminate pseudo-class to selected elements which could come in handy to show particular UI components when no radio button in a group is selected yet.

What is interesting about the property indeterminate is that you can set it to true or false and this will affect the pseudo-class for checkboxes but not for radios. Dealing with radio buttons the actual selection state of a group is always right.

These three properties can be used to figure out what a user selected and they are very straightforward to use. If the user selects text in an input field, you can use these to evaluate what was selected.

What I did to test this is that I defined an interval which logs the selection values every second. selectionStart and selectionEnd return numbers describing the position of my selection but selectionDirection surprisingly returns none when you select things with your mouse or trackpad but forward or backward when you select text using SHIFT and the arrow or control keys.

And that’s it. :)

Thanks for reading! ❤️

Add a comment

Related posts:

Lego Sorter using TensorFlow on Raspberry Pi

In early 2017 I stumbled across one of the documented Google Cloud and Tensorflow use cases titled How a Japanese cucumber farmer is using deep learning and TensorFlow. It stuck in my mind and…

Legit airdrop from XRWeb!

Just follow easy instructions and get 20 XR reward from XRWeb! #XRWeb #ExtendedReality #XRToken #ICO #BlockchainTechnology #SpatialWeb #SpatialXRApps