This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_modal | |
NSApp.beginSheet(@my_modal_window, | |
modalForWindow: @my_main_window, | |
modalDelegate: self, | |
didEndSelector:nil, | |
contextInfo:nil) | |
end | |
def cancel_modal(sender) | |
NSApp.endSheet(@my_modal_window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
framework 'Foundation' | |
framework 'ScriptingBridge' | |
terminal = SBApplication.applicationWithBundleIdentifier("com.apple.terminal") | |
load_bridge_support_file 'Terminal.bridgesupport' #load the bridge support file | |
new_tab = terminal.classForScriptingClass("tab").alloc #create a new tab instance | |
terminal.windows.first.tabs.addObject(new_tab) #add the tab to the first window | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApplication < NSApplication | |
def sendEvent(event) | |
if event.type == NSSystemDefined && event.subtype == 8 #determine if one of the media keys was pressed | |
keyCode = (event.data1 & 0xFFFF0000) >> 16 | |
keyFlags = event.data1 & 0x0000FFFF | |
keyState = (keyFlags & 0xFF00) >> 8 == 0xA | |
mediaKeyPressed(keyCode) if keyState | |
super(nil) #don't passing anything on to super | |
else | |
super(event) #not what we were looking for, pass the event on to super. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tableView(aView, acceptDrop:info, row:droppedRow, dropOperation:op) | |
pboard = info.draggingPasteboard | |
row_data_array = YAML.load(pboard.stringForType("MyRowDataType")) #grab the YAML from the pasteboard and convert it back to an array | |
row_data_array.reverse.each do |row| #You'll want to insert your rows in reverse order to maintain the indexes, thus the reverse call | |
#rearrange your table_data_array accordingly here. droppedRow represents index value of where the row was dropped. | |
end | |
table_view.deselectAll(nil) #Deselect everything after the drop | |
table_view.reloadData #redraw the table to show the updates | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tableView(aView, validateDrop:info, proposedRow:row, proposedDropOperation:op) | |
if op == NSTableViewDropAbove #is the proposed row going to be dropped between rows? | |
return NSDragOperationEvery | |
else | |
return NSDragOperationNone #it isn't between rows, deny the proposed drop | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tableView(aView, writeRowsWithIndexes:rowIndexes, toPasteboard:pboard) | |
row_data_array = [] #lets create an array to place the rows' data in | |
rowIndexes.each do |row| #for each of the rows being dragged. Row represents the index in the table's data source array | |
row_data_array << table_data_array[row] #add the data to the row_data_array | |
end | |
pboard.setString(row_data_array.to_yaml, forType:"MyRowDataType") #convert the array to YAML, then store it in the pasteboard. The type should be a custom type or your choice, unless you want to accept drops from other locations. | |
return true #the method must return true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SelectAllTable < NSTableView | |
attr_accessor :delegator #Connect this to the delegate of your table view | |
def keyDown(event) #any time this table is in focus and a key is pressed, this method will be called. | |
characters = event.characters | |
character = characters.characterAtIndex(0)#let's get the first key that was pressed | |
if character == 97 && (event.modifierFlags & NSCommandKeyMask) == NSCommandKeyMask #97 is the "A" key, while the CMD key is a modifier key. Check to see if both were pressed | |
@delegator.select_all #call your method that selects all your rows | |
else | |
super(event) #This isn't what we're looking for, pass it on to super |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UseIPv6 off | |
# If set on you can experience a longer connection delay in many cases. | |
IdentLookups off | |
ServerName "FTP.SCOTTUSA.COM -- SCOTT-SPORTS" | |
ServerType standalone | |
DeferWelcome off | |
MultilineRFC2228 on | |
DefaultServer on |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProgressIndicator < NSView | |
attr_accessor :progressPercent | |
attr_accessor :parent | |
def mouseDown(event) | |
point = convertPoint(event.locationInWindow, fromView: nil) | |
click_x = point.x #this is the point where the mouse was clicked on the x axis | |
click_y = point.y #this is the point where the mouse was clicked on the y axis | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sqlite3' | |
require 'sequel' | |
DB = Sequel.sqlite() | |
DB.create_table :entries do | |
primary_key :id | |
String :words | |
end |
NewerOlder