Skip to content

Instantly share code, notes, and snippets.

@addr010
Created October 7, 2019 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addr010/d141c86347fed31706e305afa7986e9b to your computer and use it in GitHub Desktop.
Save addr010/d141c86347fed31706e305afa7986e9b to your computer and use it in GitHub Desktop.
Show lag when using NSPopupButton
// Mod the macControls sample project to show the UI lag when using some UI elements
// This file has been autogenerated from a class added in the UI designer.
using System;
using Foundation;
using AppKit;
using MetalKit;
using CoreGraphics;
using Metal;
using System.Diagnostics;
namespace MacControls
{
public partial class MenuViewController : NSViewController, IMTKViewDelegate
{
MTKView mtlView;
Stopwatch stopwatch = new Stopwatch();
public void Draw(MTKView view)
{
FeedbackLabel.StringValue = stopwatch.Elapsed.TotalSeconds.ToString();
stopwatch.Restart();
}
public void DrawableSizeWillChange(MTKView view, CGSize size)
{
//throw new NotImplementedException();
}
void InitMetal()
{
mtlView = new MTKView(new CGRect(0, 0, 10, 10), MTLDevice.SystemDefault);
mtlView.Delegate = this;
mtlView.ClearColor = new MTLClearColor(1, 0, 0, 1);
View.AddSubview(mtlView);
stopwatch.Start();
}
#region Constructors
public MenuViewController (IntPtr handle) : base (handle)
{
}
#endregion
#region Override Methods
public override void ViewDidLoad()
{
base.ViewDidLoad();
InitMetal();
}
public override void ViewWillAppear ()
{
base.ViewWillAppear ();
}
#endregion
#region Actions
partial void ItemOne (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 1";
FeedbackLabel.StringValue = "Item One Selected";
}
partial void ItemTwo (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 2";
FeedbackLabel.StringValue = "Item Two Selected";
}
partial void ItemThree (Foundation.NSObject sender) {
DropDownSelected.Title = "Item 3";
FeedbackLabel.StringValue = "Item Three Selected";
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment