[Closed] imgtag i am really in rage
for imgtag i want really to know wat is the difference between it and bitmap according to the help the imgtag provides event hndlers according to mouse pos or cliciks itried to make the event of changing the bitmap if i clicked on pos and trie many other commands like mouseover and so but invian got nothing useful i am desiging my character ui and i want to add something better this time for the ui and i feel imgtag to be good option but the help didnt help me this time regarding imagtag i revised the topics here but didnt got good results
anyone would give me a guide to get use of these imgtag ?
Did you try the example from the Help?
When I run it and move the mouse over the red square, the Listener shows the events:
ImgTag:b5 ; #mouseover ; [4,38] ; 0
ImgTag:b5 ; #mouseDown ; [26,18] ; 1
ImgTag:b5 ; #lbuttondown ; [26,18] ; 1
ImgTag:b5 ; #mouseUp ; [21,30] ; 0
ImgTag:b5 ; #click ; [21,30] ; 0
ImgTag:b5 ; #lbuttonup ; [21,30] ; 0
ImgTag:b5 ; #mouseDown ; [36,30] ; 1
ImgTag:b5 ; #lbuttondown ; [36,30] ; 1
ImgTag:b5 ; #mouseUp ; [36,30] ; 0
ImgTag:b5 ; #click ; [36,30] ; 0
ImgTag:b5 ; #lbuttonup ; [36,30] ; 0
ImgTag:b5 ; #mouseDown ; [32,8] ; 1
ImgTag:b5 ; #lbuttondown ; [32,8] ; 1
ImgTag:b5 ; #mouseUp ; [32,8] ; 0
ImgTag:b5 ; #click ; [32,8] ; 0
ImgTag:b5 ; #lbuttonup ; [32,8] ; 0
ImgTag:b5 ; #mouseout ; [28,-1] ; 0
ImgTag:b5 ; #mouseover ; [18,0] ; 0
ImgTag:b5 ; #mouseDown ; [18,6] ; 1
ImgTag:b5 ; #lbuttondown ; [18,6] ; 1
ImgTag:b5 ; #mouseUp ; [5,21] ; 0
ImgTag:b5 ; #click ; [5,21] ; 0
ImgTag:b5 ; #lbuttonup ; [5,21] ; 0
ImgTag:b5 ; #mouseout ; [50,27] ; 0
ImgTag:b5 ; #mouseover ; [49,42] ; 0
ImgTag:b5 ; #mouseout ; [51,14] ; 0
ImgTag:b5 ; #mouseover ; [47,27] ; 0
ImgTag:b5 ; #mouseout ; [52,-5] ; 0
I have used it just fine in the past, I think that we need to know what it is you are trying to do and exactly where you are having issues. My last system and one we are currently using in production is using pictureBox controls in dotNet. I found this far more flexible but I had it working with imgTag in tests.
Ireally did ran that script and got these dat in listener still somethings vague wat are v1 and v2 variables refer to and what i do if i want to make any events to happen other than typing data in the lisener it may be silly but i couldnt make use of that i want to substitute bitmap imageby another when i run mouse over specicific part of the image but couldnt the help seems to be somewat vague regarding that part
@ shalabology
yes , sometimes the max ref seem very hard to understand , but this is not the case here
as you mentioned the v1 and v2 are variables , what they mean is clearly stated in the help
v1 is the pixel index
each control “in this case a bitmap or imgtag” is measured as rows and columns of pixels
this starts at the top left corner of the bitmap it self , meaning if you click on the first pixel of the bitmap … your mouse location according to the coordinates of that bitmap is 0 0
now if you click on the right bottom corner your coordinates “again according to that bitmap” equals [bitmap.width , bitmap.height]
this coordinate system IS NOT as the rollout coordinates , the later starts at IT’S left top corner of the client area .
now where are your mouse according to the bitmap coordinates ?
you just don’t know until you hover over it or click … etc
that’s why in the help you find v1 … its just a variable name to hold the point2 value where the event occurred .
this means if you want to invoke a specific action according to specific regions of the bitmap you should start to determine that region
in the code below i defined half of the bitmap horizontally and then vertically .
v2 is the FLAG
i’m not very familiar with that , but its simple to understand it if you tell the script to print v2
press shift and see what the listener gives you … press alt … etc
as for the documentation
you have to be familiar with it first to decipher some parts
it took me not less than a year to feel at home with it , still sometimes i find myself lost
but this goes for any language refs. i still find some c# libraries very confusing .
rollout ui_items "ui items"
(
local bm1 = bitmap 50 50 color:red
local bm2 = bitmap 50 50 color:green
local bm3 = bitmap 50 50 color:blue
local bm4 = bitmap 50 50 color:gray
local bm5 = bitmap 50 50 color:yellow
imgtag b5 "imgtag" bitmap:bm1 align:#center
on b5 lbuttondown v1 v2 do
(
if v1.x <= b5.width/2 then b5.bitmap = bm2 else b5.bitmap=bm3
)
on b5 mbuttondown v1 v2 do
(
if v1.y <= b5.height/2 then b5.bitmap = bm4 else b5.bitmap=bm5
if v2 == 20 do (messagebox "ShiftKey was pressed !") -- comment this and see the different flags in the listener
print v2
)
)
createdialog ui_items width:100
Yep, the example in that topic is not the greatest (glad I did not write it). I will try to improve it for the next version.
Here is a better description of the second argument (the button flags):
[left]The second argument is the Flags value which is a combination of the following bits:[/left]
[b]Hexadecimal[/b] [b]Decimal[/b] [b]Binary [/b] [b]Key Pressed[/b]
0x0001 1 0000000[b]1[/b] The left mouse button is down.
0x0002 2 000000[b]1[/b]0 The right mouse button is down.
0x0004 4 00000[b]1[/b]00 The SHIFT key is down.
0x0008 8 0000[b]1[/b]000 The CTRL key is down.
0x0010 16 000[b]1[/b]0000 The middle mouse button is down.
0x0020 32 00[b]1[/b]00000 The first X button is down (the left side button of the mouse)
0x0040 64 0[b]1[/b]000000 The second X button is down (the right side button of the mouse)
[left]
You can use the bit.get() method to determine whether a key is pressed or not:[/left]
[left][b][b]EXAMPLE[/b][/b][/left]
rollout ui_imgtag "imgtag"
(
local bm = bitmap 50 50 color:red
imgtag img_tag "imgtag" bitmap:bm align:#center
fn printButtonStates Flags =
(
LMB = bit.get Flags 1
RMB = bit.get Flags 2
SHIFT = bit.get Flags 3
CTRL = bit.get Flags 4
MMB = bit.get Flags 5
XB1 = bit.get Flags 6
XB2 = bit.get Flags 7
format "LMB:% MMB:% RMB:% SHIFT:% CTRL:% XB1:% XB2:%
" LMB MMB RMB SHIFT CTRL XB1 XB2
)
on img_tag lbuttondown v1 v2 do printButtonStates v2
on img_tag mbuttondown v1 v2 do printButtonStates v2
on img_tag rbuttondown v1 v2 do printButtonStates v2
)
createdialog ui_imgtag width:100
i did that ,surprisingly it doesnt show the image even i placed the the images in the script folder heres the code
rollout ui_items "ui items"
(
--bitmap the_bmp fileName:"a.bmp" bitmap:("a.bmp")
--bitmap the_bmp2 fileName:"b.jpg" bitmap:("b.bmp")
local bm3 = bitmap 250 250 fileName:"a.bmp" bitmap:("a.bmp")
local bm4 = bitmap 250 250 fileName:"b.bmp" bitmap:("b.bmp")
--local bm5 = bitmap 50 50 color:yellow
imgtag b5 "imgtag" bitmap:bm3 align:#center
on b5 lbuttondown v1 v2 do
(
if v1.x <100 then b5.bitmap =bm3 else b5.bitmap=bm4
)
on b5 mbuttondown v1 v2 do
(
if v1.y <100 then b5.bitmap = bm3 else b5.bitmap=bm4
if v2 == 20 do (messagebox "ShiftKey was pressed !") -- comment this and see the different flags in the listener
print v2
)
)
createdialog ui_items 650 500
You either have to set the path to the bitmaps explicitly, or possibly set the sysinfo.currentdir to the folder you want MAXScript to look for stuff into. Check out the GetDir() function for ways to get to various 3ds Max directories. You cannot expect a bitmap without a path to be magically found since various parts of the system look under different folders and the current system path is constantly changing.
if i may add something to the bitmap thing , if you search the help for bitmap
the first result you get is bitmap values
down the page you’ll find a function to store the bitmap as maxscript code , and you can simply store it in a maxscript file , this is slow … but it removes the path issues