Giter Site home page Giter Site logo

dagronf / dsfstepperview Goto Github PK

View Code? Open in Web Editor NEW
61.0 2.0 7.0 225 KB

A custom stepper text field for macOS and iOS, supporting Swift, Objective-C, SwiftUI and Catalyst

License: MIT License

Swift 100.00%
macos swift objective-c stepper nsstepper nstextfield swiftui ios catalyst maccatalyst

dsfstepperview's Issues

Trouble importing this module in xcode 12.3

This is most likely an error from inexperience with mac on my part (I only got it 2 days ago), but after using the swift package manager to add this module as a dependency, I was unable to then import it as in ContentView.swift... Is "import DSFStepperView" the right way/name to import it? I've imported other dependencies without an issue, this is the only one so far which gives me the "No such module 'DSFStepperView'" error.

Doc not correct

On the documentation I see this this text:
let format = NumberFormatter()
format.numberStyle = .decimal

// Always display a single digit fractional value.
format.allowsFloats = true
format.minimumFractionDigits = 1
format.maximumFractionDigits = 1

stepperView.numberFormatter = format

but have this error is try in my code
numberFormatter' is inaccessible due to 'internal' protection level

Thanks,

Suggestion for check input for macOS (only number)

Hi,

I have add a simple function for check input on the NSTextField (macOS only)

Add this extension

extension String {
func isNumber() -> Bool {
    return !self.isEmpty && self.rangeOfCharacter(from: CharacterSet.decimalDigits) != nil && self.rangeOfCharacter(from: CharacterSet.letters) == nil
}}

Add this code on the stepper view class

func
_evt(_ e:NSEvent) -> NSEvent?
{
    if e.type == .keyDown
    {
        if let s = e.characters
        {
            if s.rangeOfCharacter(from: CharacterSet.alphanumerics) == nil
            {
                return e
            }
            
            if s.isNumber()
            {
                return e
            }
            
            return nil
        }
    }
    
    return e
}

public func
use_filter()
{
    NSEvent.addLocalMonitorForEvents(matching: [.keyDown], handler: _evt)
}

Call method use_filter()

mystepper1. use_filter()

Now you can hit only number in NSTextField (alphanumbers are correct check but if you hit "%" doesn't work!)

May be is utile for you in future version ?

DSFStepperView-shared linker issue for iOS Device build

When I added this to an existing project via SPM, I was unable to get it to build to run on a device, but it ran just fine in the simulator. I received this error:

No such file or directory: '/Users/andrewmagruder/Library/Developer/Xcode/DerivedData/Multi-Tool-eltmjcbmaxjdygagnsgbmawozdfs/Build/Products/Debug-iphoneos/PackageFrameworks/DSFStepperView-shared.framework/DSFStepperView-shared'

To correct this, I went Target->Frameworks, Libraries, and Embedded Content->DSFStepperView-shared->Filters->Unchecked "Allow on any platform" && "iOS".

This cleared my linker error and now the app builds/runs on device and in simulator.

Xxode: 15.2. iOS: 17.2. Device: iPhone 14 Pro Max.

Works great! Thank you! ๐Ÿ‘

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.