Accept / Cancel action decoration

Started by Stephen T., November 19, 2015, 05:34:03 PM

Previous topic - Next topic

Stephen T.

Is there a way now or planned to simply modify the decoration (text/image) on an action? (A DIALOG class call?)

Most actions are fine as defined in a 4ad, but (and maybe this is just me) the accept and cancel buttons take on different guises. in some cases the accept means 'Select' and then could mean 'Save' or 'OK' - similarly, cancel can be 'Back', 'Exit', 'Abort', 'Cancel' etc.

Reuben B.

In the 3.0 EAP which is underway now, I have not seen you posting in there, you can override the ACTION attributes in your 4gl.  In one of my samples, I have something like ... ON ACTION accept ATTRIBUTES(TEXT="Search") for use in a CONSTRUCT statement.

Otherwise prior to 3.0 you might be able to achieve what you want via DOM tree manipulation.

Code (genero) Select
#+ action_comment_set Change the comment attribute of a given action
FUNCTION action_comment_set(action, comment)
DEFINE action, comment STRING
DEFINE n om.DomNode

   LET n = action_node_get(action)
   IF n IS NOT NULL THEN
      CALL n.setAttribute("comment", comment)
   END IF
END FUNCTION

#+ action_text_set Change the text attribute of a given action
FUNCTION action_text_set(action, text)
DEFINE action, text STRING
DEFINE n om.DomNode

   LET n = action_node_get(action)
   IF n IS NOT NULL THEN
      CALL n.setAttribute("text", text)
   END IF
END FUNCTION

#+ action_node_get Return the node that defines a given action
FUNCTION action_node_get(name)
DEFINE name STRING
DEFINE w ui.Window
DEFINE n,f om.DomNode
DEFINE nl om.nodeList

   LET w = ui.Window.getCurrent()
   LET n = w.getNode()
   LET nl = n.selectByPath(SFMT("//Action[@name=\"%1\"]",name))
   IF nl.getLength() != 1 THEN
      LET nl = n.selectByPath(SFMT("//MenuAction[@name=\"%1\"]",name))
   END IF
   IF nl.getLength() = 1 THEN
      LET f=  nl.item(1)
   END IF
   RETURN f
END FUNCTION


... its not perfect as from memory it doesn't necessarily propagate out to action views ie you had to change button, toolbar, topmenu items manually as well, whereas if I was able to persuade developers to add ui.Dialog.setText, ui.Dialog.setComment then I'd expect those methods to do that.

Reuben
Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero

Stephen T.

Reuben,
No, apologies for not signing up to the 3 EAP, but I haven't been able to dedicate time recently and am still trying to really catch up with changes in 2!
We (royal) have had a dom manipulator since the 1.10 days (I think!) - that is what prompted me - in the multi dialog that I'm using to test features, I still had to use that manipulator to change toolbar entries - and I just wondered if I'd missed a new feature.

I like the new stuff so far though - the ability to 'sub dialog' would have saved a bit of effort in the past. Good stuff.