Skip to content

Unable to use user-defined unit in NSRulerView with Microsoft.macOS sdk. #17742

@rocktyt

Description

@rocktyt

Steps to Reproduce

  1. create a NSRulerView
  2. call RegisterUnit(string unitName, string abbreviation, NFloat conversionFactor, NSNumber[] stepUpCycle, NSNumber[] stepDownCycle) to create a user-defined unit
  3. set MeasurementUnit to unitName that registered in step2

Expected Behavior

MeasurementUnit can be set

Actual Behavior

MeasurementUnit cannot be set because the type of MeasurementUnit is enum NSRulerViewUnits not string/NSString

MeasurementUnit has type string and can work when using Xamarin.Mac

Environment

Version information
Visual Studio 2022 for Mac Preview
Version 17.6 Preview (17.6 build 402)

Runtime
.Net 7.0.1 (64-bit)
Microsoft.macOS.Sdk 13.1.1007

Comment

src: https://github.com/xamarin/xamarin-macios/blob/main/src/appkit.cs#L13420
MeasurementUnit should have type string/NSString but not an enum. This makes RegisterUnit useless as registered unit cannot be used.
Inches / in, Centimeters / cm, Points / pt, Picas / pc, are just predefined units.
https://developer.apple.com/documentation/appkit/nsrulerview/1534137-registerunit

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixmissing-api-bindings

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions