The lever spinner


Case study of the LeverSpinner element

img

Example

Swift:

let leverSpinner:LeverSpinner = addSubView(LeverSpinner(140, 40,"Value: ", 0, 1, CGFloat(Int.min), CGFloat(Int.max), 0, 100, 200, self)) as! LeverSpinner;
func onEvent(event:Event){
	if(event.origin === leverSpinner && event.type == SpinnerEvent.change){(event as! SpinnerEvent).value}//here we can read the value 
}
leverSpinner.event = onEvent//We add an event handler 

In the above example there is also an example of the new super simple event system, which also works inside methods 🚀

CSS:

Spinner{
	float:left;
	clear:left;
	width:120px;
	height:24px;
	padding:-2px;
}
Spinner TextInput{
	width:90px;
	height:18px;
	margin-right:6px;
}
Spinner TextInput Text{
	width:40px;
	height:20px;
	autoSize:left;
	color:black;
	selectable,mouseEnabled:false;
	margin-top:0px;
}
Spinner TextInput TextArea{
	width:50px;
	height:18px;
}
Spinner TextInput TextArea Text{
	width:100%;
	align:right;
	selectable,mouseEnabled:true;
}
Spinner Stepper{
	clear:none;
}

Notes:

  • The variables in the css named <InsetShadow> etc. Are generic theme styles stored in a css file. An article describing how to use generic styles is coming soon.
  • The css for the Spinner component only (you also need css for the stepper. This will be introduced shortly)

Tasks:

  • [ ] Fix window movement when using custom window, only top should be draggable
  • [ ] Should not increment or decrement via upInside if movement has occurred
  • [ ] Change the Event system from calling the event variable first to calling the event method first.

Related Posts

Infinite Tree List

My notes on Infinite tree list

Protocol Inheritance

My notes on Protocol Inheritance

Protocol Ambiguity

How to differentiate protocol ambiguity

The Ultimate Xcode Workflow

Spend zero time managing dependencies

Faster Xcode With Spm

How you can speed up compile times in XCode with Swift Package Manager

Spm And Ci Travis

My notes on Swift PM + CI Travis

Spm And Nested Frameworks

My notes on Swift package manager + XCode + Nested frameworks

Xcode And Spm

Here is how you use Swift package manager in your XCode app projects

Carthage And Nested Frameworks

A few workflows concerning Carthage and nested framework

Two Finger Swipe

Notes on implementing two finger swipe for macOS