Title: frontcall cbpaste question Post by: . on October 30, 2008, 02:51:12 pm I am trying to use frontcall with cbpaste to insert a value into text in a textedit, without luck. Can anyone help find a way around it please?
I want the users to select the text to insert from a function that produces a popup menu and I think it is this going off to another function that effectively loses focus from the field I'm in, even once I've returned back to the action block. THIS WORKS (never leaving the on action block): ON ACTION myaction IF ( INFIELD(myfield) ) THEN CALL ui.Interface.frontCall("standard","cbset",["My Text"],[lv_result]) CALL ui.Interface.frontCall("standard","cbpaste",[],[lv_result]) END IF THIS DOES NOT WORK: ON ACTION myaction IF ( INFIELD(myfield) ) THEN CALL my_menu() RETURNING lv_string CALL ui.Interface.frontCall("standard","cbset",[lv_string],[lv_result]) CALL ui.Interface.frontCall("standard","cbpaste",[],[lv_result]) END IF Although, then right clicking and selected Paste will then insert the text as I want it to. I've also tried (and this doesn't work either, though not that useful anyway): ON ACTION myaction IF ( INFIELD(myfield) ) THEN CALL my_menu() RETURNING lv_string NEXT FIELD CURRENT END IF BEFORE FIELD myfield IF ( lv_string IS NOT NULL ) THEN CALL ui.Interface.frontCall("standard","cbset",[lv_string],[lv_result]) CALL ui.Interface.frontCall("standard","cbpaste",[],[lv_result]) LET lv_string = NULL END IF Title: Re: frontcall cbpaste question Post by: . on October 30, 2008, 04:12:19 pm Jeff,
From a "GDC point of view", this is unfortunately expected: cbPaste pastes the clipboard in the current field (i.e. the widget associated to the Node pointed by UserInterface.focus) if the field is "pastable" (a Menuaction can get the focus but can't be "pasted"). Code
my_menu() creates a menu which changes the focused node (the focus goes to one of the menu items). Then, when my_menu is closed and you call the frontCall, the focused node does not exists anymore ; then the runtime system set the focus to the fallback node, i.e. the UserInterface: Code
cbPaste will then do nothing because the focused node is a not a "pastable" field ; the same in the BEFORE FIELD: you're not in the field, you are BEFORE the field. Out of my head I see no clean and quick solution, I just wanted to explain you the behavior. Regards, Title: Re: frontcall cbpaste question Post by: . on October 30, 2008, 05:09:13 pm Hi Pierre-Nicolas,
Thanks for the response. Is there a way of forcing focus back to the field I am in? I never leave my field as such (although GDC sees that I did) and I am still positioned within the text edit where I was before the menu was called (menu style=popup). I have returned back from the menu into the ON ACTION block at the point where I do the cbset and cbpaste. I did try to get the cursor position to manually insert rather than using clipboard from the text edit but unfortunately the attributes cursor and cursor2 only seem to get updated when you exit the field (unfortunately, here GDC doesn't see that I did as they don't get updated). I want to know where the cursor is in the text at the point the action is triggered! If I outline what I am trying to do, maybe someone will have a solution: The user is typing into a text edit and at some point in the text (not always at the end) they want to insert a common phrase by pressing a key and selecting from a popup menu. I then want to insert that phrase at the point the cursor is at I would really appreciate if anyone has an answer. Cheers Jeff Title: Re: frontcall cbpaste question Post by: Reuben B. on October 30, 2008, 10:11:31 pm Jeff,
Does this meet your needs. Only downside I can see is if you either a) want to replace any selected text rather than just insert at the current point and b) you are using UNBUFFERED Code
Pierre-Nicolas, Maybe ui.Interface.Refresh() should update the value of the node with focus? I ran into the same issue once when attempting to use Windows SendKeys. I couldn't have an 'Are you sure you want to do this?' Menu dialog because the current field focus was lost. Is there an equivalent FGL_ function call to to get the cursor2 value? Reuben |