Hello Guest it is October 25, 2021, 07:31:38 AM

Author Topic: Mach 4 Exit button for touchscreen  (Read 1276 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach 4 Exit button for touchscreen
« Reply #10 on: December 18, 2019, 09:48:15 AM »
Quote
How does one know which API's are usable inside this programming for Mach, or is it open to any API?
.

Typically API is used to refer to the Mach 4 interfaces here. If you are asking about wxWidgets or another LUA library, that is a different thing.

In general, all the Mach API commands can be used anywhere. Some have restrictions based on the state of the machine. There are other restrictions/limitations once you start playing with LUA panels and macros, but I am not qualified to provide information on this.

wxWidgets is fully supported in Mach4, however it can get quite complicated once you get beyond the basic features. There are other libraries for LUA included in the Mach 4 install (such as RS232 serial support) and others might be able to be added, but I'm not knowledgeable in doing so.
Re: Mach 4 Exit button for touchscreen
« Reply #11 on: December 18, 2019, 09:57:56 AM »
Is there a list of all the API commands available in Mach
Re: Mach 4 Exit button for touchscreen
« Reply #12 on: December 18, 2019, 11:38:33 AM »
Hi,
yes, look in Mach4Hobby/Docs for API.chm.

Can also be accessed when Mach is enabled by clicking <Help Docs?> button in the File Ops tab.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Exit button for touchscreen
« Reply #13 on: December 19, 2019, 12:34:43 PM »
Ok so i'm trying to get mach to recognize an Enter keypress. Here is the code i found pertaining to keypress in LUA. I have a textbox that i want to enter code and when i press the enter key i want the code to run as an MDI command. The code below is supposed to recognize when an enter key is pressed, I have all this in the On Modify Script of the textbox. When i write something in the textbox and press enter nothing happens. What is the purpose of the On Modify Script, and the On Update Script?

while true do
    if keyPress(13)==true then
        wx.wxMessageBox("You Just Pressed Enter")
    end
end
Re: Mach 4 Exit button for touchscreen
« Reply #14 on: December 19, 2019, 04:35:22 PM »
Hi,
to be honest I think you are going about this the wrong way.

I still find myself hitting <Enter> occasionally after typing an MDI, a hang over from Mach3 days but I don't find using the
<MDI Cycle Start> button that onerous....but perhaps you do. What you are trying to do here is 'fix a perceived
problem that is in fact no problem at all, just a new, Mach4, way of doing things'.

Given that proviso......then you can use the keyboard plugin to capture any <Enter> keypress. If you so desire
you can cause such a keypress to issue an MDI Cycle Start.

I forsee a problem that there are a number of circumstances that you would use <Enter> keypress, not all of them
associated with MDI, are you sure you want to issue an MDI Cycle Start at EVERY <Enter> keypress?

Of course using the keyboard plugin as I am proposing you could choose other than Enter as a keypress to start an MDI command,
maybe the <Space Bar> for instance. That might reduce the number of occasions that you accidentally start an MDI command.

There is a video by Daz-the-Gaz about using the keyboard plugin.

https://www.machsupport.com/forum/index.php?topic=31585.msg219180#msg219180


The upshot is that the keyboard plugin can launch a number of 'Mach Actions' in response to a defined keypress....but what happens
if one of Machs stock actions is not what you want. That is what Daz's video is about.

You can cause the keyboard plugin to trigger a Mach signal, mc.ISIG_INPUT33, for example. Now every time you press the <Space Bar>
Input #33 would trigger. Now you just have to put Input #33 into the SigLib{} table as you would with any other input signal
and cause the appropriate action. If you are not familiar with the SigLib{} table......you are in for a treat!! It is a very VERY VERY
clever way to deal with signals, both input and output, that is new to Mach4 and not even dreamt about in Mach3. Look at my .pdf on it:

https://www.machsupport.com/forum/index.php?topic=40051.msg267764#msg267764

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Exit button for touchscreen
« Reply #15 on: December 19, 2019, 05:57:07 PM »
Hi,
re-reading the whole thread there is another possibility that may avoid the situation where a random <Enter> keypress would cause an MDI
command to be initiated.

You say you have a text box for MDI input?
Did you use wxWidgets to do it? If so why don't you include an enter event. Then the only time that the enter event would be tested is while
the text box is active.

If you haven't already tried, wxFormBuilder is the premier development tool/system for generating wxWidgets code with a Lua wrapper.
I used to try to avoid it but trying to manually craft wxWidgets code is hard going. wxFormbuilder has taught me alot about wxWidgets.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Exit button for touchscreen
« Reply #16 on: December 19, 2019, 08:19:06 PM »
I believe (you'd have to test this) it will also work using the text box screen element from the screen editor. Put the code you want executed when pressing <enter> in the On Modify Script. To get the text you entered in the text box, something like:

local textInput = select(1, ...)

It'd be good to only enable that text box when the machine is enabled, similar to how the "Cycle Start MDI" button can only be pressed if the machine is enabled.

Personally, I like the multi-line MDI  :)
Re: Mach 4 Exit button for touchscreen
« Reply #17 on: December 19, 2019, 09:53:41 PM »
Hi,

Quote
Personally, I like the multi-line MDI  :)

Me too! I often write 'chesey' little Gcode scripts in the MDI panel then hit <MDI Cycle Start> each time I want the script to run,
so simple and immediate.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach 4 Exit button for touchscreen
« Reply #18 on: December 20, 2019, 10:20:34 AM »
I also like the multi line MDI as well, but when im doing setups i like to do quick verification as im locating edges and stuff like that. So i also like to have a single line mdi textbox to perform these. We have a Tormach at work and they use a similar type textbox that i can enter a single line and hit enter and the code runs. This is what im trying to acheive.

My idea for the MDI single line textbox has always been that i would type some code into the texbox and ht enter and when i hit enter it will run. If the MDI textbox is empty then nothing happens when i hit enter. I would only like it to be triggered when there is code in the textbox. That was how i planned for not having unwanted enter events. The textbox would only be available in an idle state and not when the machine is running a program. Im sorry i should have prefaced my original post with this information so that people would know what im trying to acheive. Being very new to mach programming and LUA i am really lost at what i can do and how to get it to perform what i need. I used to previously use VB.NET and i really liked that it had event handlers like textbox.on_Enter. It made programming what i want a lot easier.

I have tried to put a simple messagebox() command in the on Modify script of the textbox but have not had success even getting that to run. When i run Mach and type code into the box and hit enter nothing happens. Im having trouble understanding when the on Modify script is triggered. I can get this same code to work if i put it into a button on click script. It will read the textbox text and display it in a messasgebox(), just won't work in the textbox on modify script.
Re: Mach 4 Exit button for touchscreen
« Reply #19 on: December 20, 2019, 11:38:34 AM »
If you put just this line:

Code: [Select]
wx.wxMessageBox("You just pressed enter")
in the On Modify Script of the text box, you click in the text box and hit enter...it does nothing?