celanajaya / numericcontrolfield Goto Github PK
View Code? Open in Web Editor NEWAn NSTextfield that supports click and drag to change values
An NSTextfield that supports click and drag to change values
We can host our README resources here. I made a short gif that demos the textfield
textFieldDemoGif: https://user-images.githubusercontent.com/10944090/28885378-927a9c9a-776a-11e7-9a8c-79a47e4037ec.gif
I have a few questions about how to handle some aspects of functionality:
Our component is designed to handle numeric values. Should we be enforcing numeric values when someone edits the textfield manually?
The textField becomes editable when a user double clicks. Should we allow developers to turn off this feature making it only editable via click/drag?
If the textField is editable, should we also be calling the custom delegate/closure in textDidEndEditing? or some similar method so the ViewController data remains consistent with the textField's contents?
Should we write/expose any custom methods for editing the cursor's appearance?
If you edit the textfield values manually, click and drag stops working.
In response to @celanajaya 's question in the comments on the AdjustableTextField, I like the idea of having both options.
Maybe we should have two controls in the demo app, one using delegation and one using the closure.
As far as naming I was thinking that onValueChanged sounds a little Androidy to me.
What do you think about valueChangedHandler and didChangeValue for the Delegate Protocol?
If there was use for it we could even add more delegate methods such as didStartDragging and didFinishDragging in case we wanted to updated to UI or wait for the final value to be ready before acting on it... possibilities
Not sure if you use some formatting tool but I have been using this:
https://github.com/nicklockwood/SwiftFormat
It's really nice. It has a Xcode plugin that I mapped to a key combo for ease of use.
It formats everything from removing empty multiple lines to correctly formatting space around parameter in functions. Highly recommended ๐
I would also help reducing noice in the diffs when doing pull requests because it would enforce us to use the same formatting.
Not critical but we should brainstorm a better name for the project/component, which will be important for discoverability if we add support for Cocoapods and when we make a nice README about it.
The current name has some issues:
If I try to describe the component in words, it's a numeric control that allows both typing-in numeric values as well as click-n-draging to adjust the value.
Garageband has a nice implementation of this kind of control:
The tempo value looks like a label but when you hover over it, the background highlights so it feels clickable. When you click on it, the cursor turns into a short dash which helps with discoverability of the drag-to-adjust feature. If you double click it turns into an editable textfield with the numbers selected so that you can immediately start typing.
Name brainstorming:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.