WhoCanDo Posted December 3, 2013 Share Posted December 3, 2013 Using the following Vectorscript example straight from the help I have inserted the line SetFocusOnItem (id, 7); but I can't get it to work. Have I tried different locations and different component IDs but it has no effect. What's wrong? PROCEDURE CreateDialog; VAR id: LONGINT; result : LONGINT; BEGIN id := CreateLayout ('Revise Layer Link', TRUE, 'Update', 'Cancel'); CreateStaticText (id, 4, 'Relink to:', -1); CreatePulldownMenu (id, 5, 32); CreateGroupBox (id, 6, 'Link Options', TRUE); CreateCheckBox (id, 7, 'Link object is locked'); CreateCheckBox (id, 8, 'Name Link:'); CreateEditText (id, 9, 'Untitled Link', 26); SetFirstLayoutItem (id, 4); SetBelowItem (id, 4, 6, 0, 0); SetFirstGroupItem (id, 6, 7); SetBelowItem (id, 7, 5, 0, 0); SetBelowItem (id, 5, 8, 0, 0); SetBelowItem (id, 8, 9, 0, 0); SetFocusOnItem (id, 7); result := RunLayoutDialog (id, NIL); END; RUN(CreateDialog); Quote Link to comment
MullinRJ Posted December 3, 2013 Share Posted December 3, 2013 Who, ???SetFocusOnItem() is described in the VSFR as "Sets the keyboard input focus on the specified item.", which doesn't say much, but it looks like it's used with entering text into a dialog; so it needs to be executed from the event loop that controls the dialog when it is running and not in the dialog definition code. ???If you add this overly SIMPLISTIC event loop procedure to your code: ??????procedure eventLoop(var item: Longint; data :Longint); ??????Begin ?????????SetFocusOnItem (id, 7);???{ do this on every event } ??????End;???{ eventLoop } AND, call the event loop by changing your RunLayoutDialog() statement to this: ??????result := RunLayoutDialog (id, eventLoop); you might notice that every time you generate an event in your dialog your checkbox will highlight, and if you hit the Space Bar repeatedly your checkbox will toggle. ???I'm pretty sure this is not what your are trying to achieve, but the command will do something if it is executed in the right place. Describe your desires in more detail and you should get better responses to your problem. Raymond Quote Link to comment
WhoCanDo Posted December 3, 2013 Author Share Posted December 3, 2013 (edited) You guessed it Raymond, that's not what I want to do. This is my first attempt at moving to the modern dialog procedures so I am at layout stage at the moment. With the code below I will want to start in the Client text box and move to Del. Date, Rev., Part'rs, By, and Date. So the tabbing sequence should be 1, 2, 3, 4, 5, 6, OK as seen in the popup Dialog box. In the old dialog procedures, tabbing was sequenced on the componentID. procedure TB; procedure User_Form1; var i : integer; TBdialog1, result : longint; begin TBdialog1 := CreateLayout ('Title Block Text', False, 'OK', 'Cancel'); CreateStaticText (TBdialog1, 5, 'Rev.:', 6); CreateEditText (TBdialog1, 6, '3', 3); CreateStaticText (TBdialog1, 7, 'Part`rs:', 8); CreateEditText (TBdialog1, 8, '4', 43); CreateStaticText (TBdialog1, 9, 'By:', 5); CreateEditText (TBdialog1, 10, '5', 7); CreateStaticText (TBdialog1, 11, 'Date:', 6); CreateEditText (TBdialog1, 12, '6', 11); CreateStaticText (TBdialog1, 1, 'Client:', 14); CreateEditText (TBdialog1, 2, '1', 53); CreateStaticText (TBdialog1, 3, 'Del. Date:', 14); CreateEditText (TBdialog1, 4, '2', 11); SetFirstLayoutItem (TBdialog1, 5); { Rev } SetRightItem (TBdialog1, 5, 6, 0, 0); { Rev Box } SetRightItem (TBdialog1, 6, 7, 0, 0); { Rev Part'rs } SetRightItem (TBdialog1, 7, 8, 0, 0); { Rev Part'rs Box } SetRightItem (TBdialog1, 8, 9, 0, 0); { Rev By } SetRightItem (TBdialog1, 9, 10, 0, 0); { Rev By Box } SetRightItem (TBdialog1, 10, 11, 0, 0); { Rev Date } SetRightItem (TBdialog1, 11, 12, 0, 0); { Rev Date Box } SetBelowItem (TBdialog1, 5, 1, 0, 0); { Client } SetRightItem (TBdialog1, 1, 2, 0, 0); { Client Box } SetRightItem (TBdialog1, 2, 3, 0, 0); { Del. Date } SetRightItem (TBdialog1, 3, 4, 0, 0); { Del. Date Box } result := RunLayoutDialog (TBdialog1, Nil); end; begin User_Form1; end; run(TB); Edited December 3, 2013 by WhoCanDo Quote Link to comment
WhoCanDo Posted December 4, 2013 Author Share Posted December 4, 2013 Maybe you are right Raymond but what you suggested doesn't work for me. SetFocusOnItem (TBdialog1, 2) doesn't do what it says. Here's where I am today: procedure TB; var Client, DelDate : string; TBdialog1, Result : longint; procedure Dialog_Handler_1 (var Item : longint; Data : longint); begin SetFocusOnItem (TBdialog1, 2); GetItemText (TBdialog1, 2, Client); GetItemText (TBdialog1, 4, DelDate); end; procedure User_Form1; begin TBdialog1 := CreateLayout ('Title Block Text', False, 'OK', 'Cancel'); CreateStaticText (TBdialog1, 5, 'Rev.:', 6); CreateEditText (TBdialog1, 6, '3', 3); CreateStaticText (TBdialog1, 7, 'Part`rs:', 8); CreateEditText (TBdialog1, 8, '4', 43); CreateStaticText (TBdialog1, 9, 'By:', 5); CreateEditText (TBdialog1, 10, '5', 7); CreateStaticText (TBdialog1, 11, 'Date:', 6); CreateEditText (TBdialog1, 12, '6', 11); CreateStaticText (TBdialog1, 1, 'Client:', 14); CreateEditText (TBdialog1, 2, '1', 53); CreateStaticText (TBdialog1, 3, 'Del. Date:', 14); CreateEditText (TBdialog1, 4, '2', 11); SetFirstLayoutItem (TBdialog1, 5); { Rev } SetRightItem (TBdialog1, 5, 6, 0, 0); { Rev Box } SetRightItem (TBdialog1, 6, 7, 0, 0); { Rev Part'rs } SetRightItem (TBdialog1, 7, 8, 0, 0); { Rev Part'rs Box } SetRightItem (TBdialog1, 8, 9, 0, 0); { Rev By } SetRightItem (TBdialog1, 9, 10, 0, 0); { Rev By Box } SetRightItem (TBdialog1, 10, 11, 0, 0); { Rev Date } SetRightItem (TBdialog1, 11, 12, 0, 0); { Rev Date Box } SetBelowItem (TBdialog1, 5, 1, 0, 0); { Client } SetRightItem (TBdialog1, 1, 2, 0, 0); { Client Box } SetRightItem (TBdialog1, 2, 3, 0, 0); { Del. Date } SetRightItem (TBdialog1, 3, 4, 0, 0); { Del. Date Box } end; begin User_Form1; if (VerifyLayout (TBdialog1) = True) then Result := RunLayoutDialog (TBdialog1, Dialog_Handler_1); { Result is OK (1) or Cancel (2) } if (Result = 1) then message (Client, ' ', DelDate); end; run (TB); Quote Link to comment
DeSignature Posted December 4, 2013 Share Posted December 4, 2013 I think VW reserves TBdialog1 for the OK-button and TBdialog2 for the Cancel-button, by default. So you should start by CreateStaticText (TBdialog1, 3, 'Client:', 14); I've tried to change your script by doing so, but VW crashed when hitting any button. I guess the cause could be found in non-definition of the Ok-button and/or the Cancel-button, but I also guess that some people might cotradict this ... Anyway ... the code below doesn't crash, and I'm sure it's susceptible to some improvements: PROCEDURE TB; VAR Client, DelDate : STRING; TBdialog1, Result : LONGINT; PROCEDURE Dialog_Layout; BEGIN TBdialog1 := CreateLayout ('Title Block Text', FALSE, 'OK', 'Cancel'); CreateStaticText (TBdialog1, 03, 'Client:', 14); CreateEditText (TBdialog1, 04, '1', 53); CreateStaticText (TBdialog1, 05, 'Del. Date:', 14); CreateEditText (TBdialog1, 06, '2', 11); CreateStaticText (TBdialog1, 07, 'Rev.:', 6); CreateEditText (TBdialog1, 08, '3', 3); CreateStaticText (TBdialog1, 09, 'Part`rs:', 8); CreateEditText (TBdialog1, 10, '4', 43); CreateStaticText (TBdialog1, 11, 'By:', 5); CreateEditText (TBdialog1, 12, '5', 7); CreateStaticText (TBdialog1, 13, 'Date:', 6); CreateEditText (TBdialog1, 14, '6', 11); SetFirstLayoutItem (TBdialog1, 07); SetRightItem (TBdialog1, 07, 08, 0, 0); SetRightItem (TBdialog1, 08, 09, 0, 0); SetRightItem (TBdialog1, 09, 10, 0, 0); SetRightItem (TBdialog1, 10, 11, 0, 0); SetRightItem (TBdialog1, 11, 12, 0, 0); SetRightItem (TBdialog1, 12, 13, 0, 0); SetRightItem (TBdialog1, 13, 14, 0, 0); SetBelowItem (TBdialog1, 07, 03, 0, 0); SetRightItem (TBdialog1, 03, 04, 0, 0); SetRightItem (TBdialog1, 04, 05, 0, 0); SetRightItem (TBdialog1, 05, 06, 0, 0); END; PROCEDURE Dialog_Handler_1 (VAR Item: LONGINT; Data: LONGINT); PROCEDURE Dialog_Events; BEGIN SetFocusOnItem (TBdialog1, 04); END; PROCEDURE Confirm_Events; BEGIN GetItemText (TBdialog1, 04, Client); GetItemText (TBdialog1, 06, DelDate); END; PROCEDURE Cancel_Events; BEGIN END; BEGIN CASE Item OF SetupDialogC: Dialog_Events; 01: Confirm_Events; 02: Cancel_Events; END; END; BEGIN Dialog_Layout; IF VerifyLayout (TBdialog1) THEN Result := RunLayoutDialog (TBdialog1, Dialog_Handler_1); IF (Result = 1) THEN Message ('Client: ', Client, Chr (13), 'Delivery Date: ', DelDate); END; RUN (TB); Quote Link to comment
WhoCanDo Posted December 4, 2013 Author Share Posted December 4, 2013 Thanks DeSignature, you've killed two birds with one stone. You are right, componentID 1 & 2 are reserved for OK & Cancel. Also, by identifying this, you have resolved the issue of Tab sequence. After removing 1 & 2 I don't need SetFocusOnItem because, as I assumed, the Tab sequence starts with 3 and moves through the componentID sequentially. Hope this post helps others because finding this information from Vectorworks Help is impossible. I'm happy ..... for now. Quote Link to comment
Vectorworks, Inc Employee klinzey Posted December 4, 2013 Vectorworks, Inc Employee Share Posted December 4, 2013 You should start your control IDs at 4. 1 is OK. 2 is Cancel. 3 is the help control. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.