Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/Custom NSView without CocoaControl


Required plugins for this example: MBS MacControls Plugin, MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/Custom NSView without CocoaControl

This example is the version from Mon, 27th Jan 2013.

Project "Custom NSView without CocoaControl.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
End Control
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
EventHandler Sub Open() n=new CustomNSView(0,0, 100, 100) dim w as NSWindowMBS = self.NSWindowMBS w.contentView.addSubview n End EventHandler
Property n As CustomNSView
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class CustomNSView Inherits CustomNSViewMBS
EventHandler Sub DrawRect(g as NSGraphicsMBS, left as double, top as double, width as double, height as double) g.SetColorRGB 1.0,0.0,0.0,1.0 g.fillRect left,top,width,height End EventHandler
EventHandler Function acceptsFirstMouse(e as NSEventMBS) As boolean Return true End EventHandler
EventHandler Function acceptsFirstResponder() As boolean Return true End EventHandler
EventHandler Function becomeFirstResponder() As boolean Return true End EventHandler
EventHandler Function canBecomeKeyView() As boolean Return true End EventHandler
EventHandler Function keyDown(e as NSEventMBS) As boolean window1.Title = CurrentMethodName+": "+str(e.keyCode) End EventHandler
EventHandler Function mouseDown(e as NSEventMBS, x as double, y as double) As boolean window1.Title = CurrentMethodName+": "+str(x)+" "+str(Y) End EventHandler
End Class
End Project

See also:

The items on this page are in the following plugins: MBS MacControls Plugin.


The biggest plugin in space...