PDA

View Full Version : really newbe question xcode cocoa buttons linking type question




paddy learner
Nov 21, 2005, 05:40 AM
For my project I have made a window in xcode cocoa IB

The window has five text fields running from left to right
built using the matrix drag replicate system

Build and run and you can tab right or shift tab left

Project requirement

arrow keys left and right will also do tab left and right
using ibook g4 keyboard

any ideas

Paddy Learner



robbieduncan
Nov 21, 2005, 08:03 AM
It's not going to be that easy (sorry).

Left and right are used to move around in the text in the text fields. Stopping this behaviour will require subclassing the cell used to dislay the fields and doing your own key handling.

paddy learner
Nov 21, 2005, 08:53 AM
robbieduncan ...It's not going to be that easy (sorry).

Ok would changing the text fields to table colums be easier

in that case I would have a table colun five frames across

being a table colum it will have at least two cells one a header and the lowwer cell would probably be for data

Would that make the problem easier to solve arrow left arrow right

what I need is other methods to tab arrow keys and /or alfa keys

it,s not critical whether it is textfield tableColoums or any other choice such as radio buttons but it needs to highlight as it tabs left or right

open to any suggestions that take the easiest route requiring the least or no code

Paddy Learner

robbieduncan
Nov 21, 2005, 09:30 AM
Using a table will not really help. When one of the text fields has input focus it will still grab all the right/left key press requests. If you wanted to use a table the solution would be identical: subclass the cell and override the keyboard handling (you can pass most of it on to the superclass).

Views contain one or more cells which they use to draw content etc. If you override NSMatrix you can override keyDown (in NSResponder) (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSResponder.html#//apple_ref/occ/instm/NSResponder/keyDown:). You can then perform your own action on left/right and class the superclass implementation for all others.

If this is the route you want to follow highlight the Matrix in IB and the go to class view. Create a subclass of NSMatrix then swtich back to instance view and switch the custom class of the matrix to your new view. Switch back to class view and create the files and then edit them in XCode.

paddy learner
Nov 21, 2005, 10:43 AM
If nessary I will pursue the recommendations above

If however I can achieve the results with illusion and less code that would be my preference

In an example from Vermont there exist an arrow left arrow right

mouse event arrow moves you in the Z direction and you can go down or up three levels

In my case would making five Z levels with the exact same picture five text fields displayed and depending on the Z level the text field would be signified by Either/OR a hghlighted textfield or a symbol in OR above the text field to signify the increment left or right

all ears for simplex solutions if they exist as my coding abilities are kinda limited to java

Paddy Learner

paddy learner
Nov 22, 2005, 06:14 AM
In the two pitures I have included all the possible varations that might be cannditates for this exersize

but if moving some colured blob across the screen is easier to do it would be great if you could let me know

in the first piture the program starts in the centre position
an event (PREFERABLY)arrow left but can if its a real big prob;em settle for mouse event on the button left to create the result in the second piture

in the second piture the fields textfield .slider ,nscolor ,nssegment etc all increment by one unit to the left

IT IS NOT MADITORY to pass any data of any sort but if passing data to a textfield or other source can easly be included then its ok to pass some data symbol such as text or mayby number etc

that explains the suggested x versus 0 in some examples

Taking a guess say the slider option was the easiest to use and do would the easiest solution be to create five piture grams similar to cards and using card shuffle in the Z axis give the illision of incrementing down and up so looking like increment left and right

or is thier better solutions

My preference is for the least code solution and so knowing which would be easiest to do will speed up solution

paddy learner
Dec 6, 2005, 09:24 AM
this is a copy of what I am showing in another forum www.xcodeforums.com
http://www.xcodeforums.com/forum/viewtopic.php?t=29
its not all the solution but part of it



Please be patient it could take a few hours or days to get pics example up on screen

As it is a small component of my college project and exams loom
I might not get the time to finish all the niceties so if others want to supply pics or comments for modification better instructions etc feel free to go with the discussion

NO CODE Tab Button SR example s and this is a bit buggy

I am a total newbie to XCODE AHHHHHH

This small example XCODE program ( uses no code )
might be useful to others
as XCODE examples that don’t use any code are rarer than hens teeth


description first pics later

open xcode and make new program application call it LeftRight

then open IB from xcode using the main

First step from IB is to drag onto the window a Tab View

that’s the symbol above the custom view with two tabs at the top
marked TAB and VIEW

stretch it a bit in width and lose a bit of height

Then highlight this component and you will get the NSTabViewItem inspector

Chose three tabs elements and name them left middle and right
go to each tab and rename left middle right

Build and run to verify all went correctly
it should tab left or right with left right arrows

The buggy part is that it wraps around
I would like to find a way to limit the tab to left middle right and no wrap


In speech recognition
(calibrate this and practice this with what time is it etc )

using ESC key or the command system say
" define a keyboard command"

The application LeftRight must be running at this time

A box will drop down and enter into the key box part ctrl left arrow

the box will retreat and the next box will say when statement is and so you type "left"

now check the radio button say is for application LeftRight and then save

Now using ESC or command speak LEFT and the tab will tab left and the computer each time it tabs will say left

Now repeat the same for right and it will now tab left and right

Right often takes several times saying right to get it to work so I might later try another word like rite or not left or.......???


The next stage is to stop the application and drag down two buttons
name the left button left and right button right


highlight the left button
Using the control drag drag the blue line up to the tab view screen
SO THAT NSTabView screen high lights

The NSButton Inspector will come up in the connections mode with blue high light on target/ actions and a large list of options will be available from fax print select tab,,,,,,,,etc

With the left button we want left moving so choice

selectPreviousTabViewItem click on that and little symbol appears beside it

build and run

pressing the left button the tabs move left

repeat process for right button but use selectNextTabViewItem

The buttons left right does not do wrap around
and in xcode when you try to force button past limits
an out of bounds appears in xcode windows
but application just flashes blue on the relevant button

An extra option is to go back to IB and highlight buttons and with button left under attributes for NSButton inspector change the key equivalent to
"z" and for right button to "x"

build run

now you can tab left right
using mouse left right
key z or x for left right
arrow left right
or speak left right


I have also a similar example that requires two lines of code to do the same job and will show that another time

I have extended the first example to have 7 elements in the tabs fields starting at -3 going to number three


I am working on having a re-centre button so it re-centers on tab 0
Also building some type of text field that shows the present tab position such as -2
inserting the number three will cause the tabbing to jump to tab position 3

then later again I would like a unlimited tab so that continual tabbing will just keep growing in size with the demand


My preference will be to try to do all that using no code if possible

If others want to contribute feel free


Pics in next few posts

Paddy Learner

paddy learner
Dec 6, 2005, 09:42 AM
For complete newbies this is expermental code stabilty and other problems not siorted out

It is best to look at apple site currency convertor for full descriptions of basic steps for setting up XCODE

the basic pics are probably sufficient for those who have done a few basic xcode applications

first few pics are nearly self explanatory so few if any notes along side but previous notes abonve may help

the first four pics are typical set up the xcode application type views

the last pic is where the xcode application LeftRight302 is made

paddy learner
Dec 6, 2005, 09:53 AM
previous pics basic set up

next few pics continuation of setting up XCODE to do program
LeftRight302

note often pics show LeftRight302 and LeftRight303 ignore this descrepincy
the running final version I have is LeftRight302

ist pic is where IB is opened

2nd pic is where on the right hand side the pallete choice is changed to costom view

3rd pic is where the window is reduced in size and renamed LeftRight302 and some radio buttons are changed in top right window inspector (NSWindowInspector)

paddy learner
Dec 6, 2005, 10:28 AM
the next few pics will get write ups later under pressure for time

ist pic drag a tab voew icon fr4om the pallette right top to the window right bottom

2nd pic strecth the icon in width and lose some height
also increase the tab element on the right top NSTabView inspector to 3
pay attension to choice for later it decides which position program starts in


3rd pic rename the element tabs left middle right

4th pic chose the middle to be the starter in progam in NSTabViewInspector top left

5th pic save all or save IB

paddy learner
Dec 6, 2005, 10:30 AM
pics

1st pic Xcode building application



2nd pic Aplication running can only tab left right using arrow left right buttons
and wraps around


3rd pic NB it apppears the application must continue to run to attach the SR
(speech recognition) to the application
I havent found another option?

Blue button SR command GUI dragged to centre screen
(possition not essentisal for use just for photo pic )
mouse on event GUI and choises appear choose open speech command window
(Probably best to have practiced this SR and calibrated it first if not fimilar with it)
Then pressing key ESC(or saying command option) speak the command
"define a keyboard command"

(I havent found a way to do this with coding or text instruction as another optioncould be useful if in noisy or public background boy do you look stupid saying ten times
this command in the college resterant- )


4th pic The RS window appears with a flap enter into the flap ctrl arrow by pressing ctrl button and then arrow left buttonand ctrl+left arrow appears in the text field and save
( I tried left arrow without control and other keys like z but they didnt work at the time so the other option may exist)

flap retreats



5th pic now type in the word " left " and click the radio button option for the name of your application in this case LeftRight302

now applicatin tabs left with voice command and computer repeats left each time it recieves left instruction event

Repeat procces for right button ussing right arrow instead
proccess will go left and right but no wrap around

paddy learner
Dec 6, 2005, 10:35 AM
pics


exit build click on red stop button relaunch IB click on main

1st pic drag a button from pallete top right to window bottom left adjust wioth aqua

2nd pic top left NSButton inspector rename button "left"

(optional key equivalent change to key z in text field)

(optional Rebuild run test verify that button flashes in mouse event but dos'nt have link to tabbing and exit relaunch IB)


3rd pic highlighting button control drag blue line to NSTabView and release


4th pic NSButtonInspector top left opens and show option for connections
mouse click on highlight SelectPreviousTabViewItem and then clmouse click on connect option
and it changes to dissconnect

save build run

now it tabs left with mouse event on button and if included tabs left with z key

rstop relaunc IB and repeat proccess for right button except choose SelectNextTabViewItem
save build run
tabs left right with arrow left right key z or x voice left right mouse event click on left or right button

paddy learner
Dec 7, 2005, 07:39 AM
My apple is 2 month old g4 12inch laptop with tiger and xcode 2

If other come back with similar or older versions of xcodes or OSX etc and it does and dosnt work that would be useful information

If anybody wants to try out this application and improve or add on extra optons feel free
If any body knows better solution or methods all ears
If somebody sees a fatal flaw to this such as inbuilt instabilty all ears

If somebody want to write up the same thing in hard code such as carbon or java equivelant that would be interesting for comparrison

Paddy Learner